Vacuum and Autovacuum Postgres Databases
This chapter describes how to vacuum the postgres database in Microsoft Windows and Linux.
This chapter includes the following sections:
Background Information
It is critical to vacuum postgres databases in order for the databases to function properly. Through the life of the database, new entries are added and current entries are updated. By design, the postgres database does not remove the iterations of a record immediately as it gets updated. Therefore, postgres databases can contain many stale, unused records. These old records must be removed at least every two weeks with the vacuum function in order to reduce disk usage and improve the speed of database queries. It is even more effective if you configure postgres automatically to vacuum the database without the need to stop the DCNM services.
Note |
$INSTALLDIR throughout this article refers to C:\Program Files\Cisco Systems\ or /usr/local/cisco/ based on the operating system, Microsoft Windows, or Linux respectively. The install path could be changed from these defaults during installation. |
Vacuum PostgreSQL Database in Windows
Procedure
Step 1 |
Stop the DCNM services by clicking Stop DCNM Servers button, or enter the followinng command: |
||
Step 2 |
Obtain the database name, username, and password. Locate the postgresql.cfg.xml file on the DCNM server. |
||
Step 3 |
Open PgAdmin III.exe, which is a helpful GUI for the postgres database. Right-click the object in the list and connect to the database. Enter the password from Step 2. |
||
Step 4 |
Navigate through the drop-down menus to the dcmdb database. |
||
Step 5 |
Right-click dcmdb and select Maintenance. Select the Vacuum, Full, Analyze, and Verbose options in the Maintain Database dcmdb dialog box.
|
Vacuum PostgreSQL Database in Linux
Procedure
Step 1 |
Stop the applications using the appmgr stop dcnm command. |
Step 2 |
Open the PSQL prompt: |
Step 3 |
Run the database vacuum and quit. Many pages of output pass on the screen. The vacuum is finished when you see a message similar to this one: Current limits are: 532000 page slots, 1000 relations, using 3182 kB. VACUUM dcmdb=> dcmdb=> \q The previous command exits the SQL prompt. |
Step 4 |
Start DCNM services by using the appmgr start dcnm command. |