Cost-based vacuuming
Running a regular VACUUM
command is a pretty intensive operation. It's likely to become the most resource intensive process running on your server, and if autovacuum ran in that fashion it would be unusable in many environments.
Fortunately there's another approach available. Cost-based vacuuming limits the amount of disk I/O any given vacuum or autovacuum process is expected to do per unit of time. It works by assigning an estimated cost to every I/O operation, accumulating a total for each operation it performs, then pausing once an upper limit on cost per iteration is exceeded.
The cost estimation presumes three basic operations vacuum performs, each with their own presumed amount of work to handle:
- Page hit: A data page was needed, but found in the shared buffer cache. It merely needs to be scanned for dead rows, with no physical I/O involved. This has a reference cost of one unit using
vacuum_cost_page_hit
, and you shouldn't ever adjust it. ...