One of the ways to maintain a database and the tables in it are by using the VACUUM or vacuumdb command. VACUUM is a PostgreSQL command that can be accessed from any database. The vacuumdb command is a system command. They both perform the same functionality, which is to clean and analyze the PostgreSQL database.
We recommend you perform a VACUUM or vacuumdb:
if you have active production databases running. You should execute the VACUUM command every night to remove any expired rows and create more space.
when a large object or number of records has been added to or deleted from the database. This allows the query optimizer to run at a more efficient pace.