| The PostgreSQL 9.0 Reference Manual - Volume 3 - Server Administration Guide
by The PostgreSQL Global Development Group Paperback (6"x9"), 274 pages ISBN 9781906966072 RRP £9.95 ($14.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
9.1.1 Vacuuming Basics
PostgreSQL's
VACUUM command has to
process each table on a regular basis for several reasons:
- To recover or reuse disk space occupied by updated or deleted rows.
- To update data statistics used by the PostgreSQL query planner.
- To protect against loss of very old data due to transaction ID wraparound.
Each of these reasons dictates performing VACUUM operations
of varying frequency and scope, as explained in the following subsections.
There are two variants of VACUUM: standard VACUUM
and VACUUM FULL. VACUUM FULL can reclaim more
disk space but runs much more slowly. Also,
the standard form of VACUUM can run in parallel with production
database operations. (Commands such as SELECT,
INSERT, UPDATE, and
DELETE will continue to function normally, though you
will not be able to modify the definition of a table with commands such as
ALTER TABLE while it is being vacuumed.)
VACUUM FULL requires exclusive lock on the table it is
working on, and therefore cannot be done in parallel with other use
of the table. Generally, therefore,
administrators should strive to use standard VACUUM and
avoid VACUUM FULL.
VACUUM creates a substantial amount of I/O
traffic, which can cause poor performance for other active sessions.
There are configuration parameters that can be adjusted to reduce the
performance impact of background vacuuming--see
section 4.4.3 Cost-Based Vacuum Delay.
| ISBN 9781906966072 | The PostgreSQL 9.0 Reference Manual - Volume 3 - Server Administration Guide | See the print edition |