Select to view content in your preferred language

Clean Up ArcGIS Monitor Postgres Database

1417
12
Jump to solution
01-10-2024 12:07 PM
SteveMcCarthy
Regular Contributor

My PostgreSQL directory has grown to 810 GB and I would like to reduce the size of this.  I have adjusted my reporting frequency to help this in the future.

Is there a way to reduce the size of this database and keep my historical data?

1 Solution

Accepted Solutions
SteveMcCarthy
Regular Contributor

This was resolved when I upgraded to Monitor 2023.3.1.

View solution in original post

0 Kudos
12 Replies
SteveMcCarthy
Regular Contributor

Can the vacuumdb be used to reduce the size of the ArcGIS Monitor Postgres Database?

0 Kudos
AndrewSakowicz
Esri Contributor

In short, no. You need to drop partitioned data as per below.

ReeseFacendini
Esri Regular Contributor

The best way to reduce the size of the database is to configure the database retention policy to delete data more frequently than 180 days (60 to 90 days perhaps). 

SteveMcCarthy
Regular Contributor

So this will remove the data older then the retention policy?  How long does that take?

I changed it from 180 to 60 days,

0 Kudos
MarceloMarques
Esri Regular Contributor

Configure database settings—ArcGIS Monitor | Documentation

in the doc link above see "Configure data retention policies".

You still need to perform regular maintenance for the PostgreSQL database, see example below, I execute this every Sunday.

-----------------------------------

set hh=%time:~0,2%
set stamp=%date:~4,2%-%date:~7,2%-%date:~12,2%_%hh%%time:~3,2%%time:~6,2%
set stamp=%stamp: =%

echo Begin: %stamp%

SET PGDIR="C:\Program Files\PostgreSQL\14\bin"
SET PGPASSWORD=*****

%PGDIR%\psql --version

echo Vaccum: %date% %time%
%PGDIR%\psql -p 5434 -U postgres -w -d agmon1 -c "vacuum"

echo Reindex: %date% %time%
%PGDIR%\psql -p 5434 -U postgres -w -d agmon1 -c "reindex database topo1"

echo Analyze: %date% %time%
%PGDIR%\psql -p 5434 -U postgres -w -d agmon1 -c "analyze"

-----------------------------------

| Marcelo Marques | Esri Principal Product Engineer | Cloud & Database Administrator | OCP - Oracle Certified Professional | "In 1992, I embarked on my journey with Esri Technology, and since 1997, I have been working with ArcSDE Geodatabases, right from its initial release. Over the past 32 years, my passion for GIS has only grown stronger." | “ I do not fear computers. I fear the lack of them." Isaac Isimov |
AndrewSakowicz
Esri Contributor

To clarify, ArcGIS Monitor admins don’t need to run manually the above maintenance. The autovacume and autoanalyze are sufficient. 


You can check with the following sql:
select relname,last_autovacuum, last_autoanalyze from pg_stat_user_tables
where last_autoanalyze is not null

In some cases, these default jobs might be interrupted (e.g. locks, see below) or not running.  In that case, a manual analyze (as above or using PGAdmin UI) might be required. Keep in mind, it will place a lock and interfere with data collections while it’s executing.


For more information , see documentation.

https://www.postgresql.org/docs/current/routine-vacuuming.html#AUTOVACUUM

For many installations, it is sufficient to let vacuuming be performed by the autovacuum daemon, which is described in Section 25.1.6.


Autovacuum workers generally don't block other commands. If a process attempts to acquire a lock that conflicts with the SHARE UPDATE EXCLUSIVE lock held by autovacuum, lock acquisition will interrupt the autovacuum.
Warning
Regularly running commands that acquire locks conflicting with a SHARE UPDATE EXCLUSIVE lock (e.g., ANALYZE) can effectively prevent autovacuums from ever completing.

ReeseFacendini
Esri Regular Contributor

The database maintenance schedule is when it will run and clear out the items. You can click the "run now" button (below the retention policy table) to fire off that process now.

SteveMcCarthy
Regular Contributor

I don't see the run button.  I'm running version 2023.2.

SteveMcCarthy_0-1704923935421.png

 

0 Kudos
AndrewSakowicz
Esri Contributor

2023.2 does not have run now option, but the job will be executed daily