next up previous contents index
Next: VACUUM ANALYZE Up: Performance Previous: CLUSTER

  
VACUUM

 When POSTGRESQL updates a row, it keeps the original copy of the row in the table file and writes a new one. The original row, marked as expired, is used by other transactions still viewing the database in its prior state. Deletions are similarly marked as expired, but not removed from the table file.

The VACUUM command removes expired rows from the file. In the process, it moves rows from the end of the table into the expired spots, thereby compacting the table file.

You should run VACUUM periodically to clean out expired rows. For tables that are heavily modified, it is useful to run VACUUM every night in an automated manner. For tables with few modifications, VACUUM should be run less frequently. The command exclusively locks the table while processing.

You can run VACUUM in two ways. Using VACUUM alone vacuums all tables in the database. Using VACUUM tablename vacuums a single table.


Bruce Momjian
2001-05-09