438438 </para>
439439
440440 <para>
441- <command>VACUUM</> normally skips pages that don't have any dead row
442- versions, but those pages might still have row versions with old XID
443- values. To ensure all old row versions have been frozen, a
444- scan of the whole table is needed.
445- <xref linkend="guc-vacuum-freeze-table-age"> controls when
446- <command>VACUUM</> does that: a whole table sweep is forced if
447- the table hasn't been fully scanned for <varname>vacuum_freeze_table_age</>
448- minus <varname>vacuum_freeze_min_age</> transactions. Setting it to 0
449- forces <command>VACUUM</> to always scan all pages, effectively ignoring
450- the visibility map.
441+ <command>VACUUM</> uses the <link linkend="storage-vm">visibility map</>
442+ to determine which pages of a relation must be scanned. Normally, it
443+ will skips pages that don't have any dead row versions even if those pages
444+ might still have row versions with old XID values. Therefore, normal
445+ scans won't succeed in freezing every row version in the table.
446+ Periodically, <command>VACUUM</> will perform an <firstterm>aggressive
447+ vacuum</>, skipping only those pages which contain neither dead rows nor
448+ any unfrozen XID or MXID values.
449+ <xref linkend="guc-vacuum-freeze-table-age">
450+ controls when <command>VACUUM</> does that: all-visible but not all-frozen
451+ pages are scanned if the number of transactions that have passed since the
452+ last such scan is greater than <varname>vacuum_freeze_table_age</> minus
453+ <varname>vacuum_freeze_min_age</>. Setting
454+ <varname>vacuum_freeze_table_age</> to 0 forces <command>VACUUM</> to
455+ use this more aggressive strategy for all scans.
451456 </para>
452457
453458 <para>
454459 The maximum time that a table can go unvacuumed is two billion
455460 transactions minus the <varname>vacuum_freeze_min_age</> value at
456- the time <command>VACUUM</> last scanned the whole table. If it were to go
461+ the time of the last aggressive vacuum. If it were to go
457462 unvacuumed for longer than
458463 that, data loss could result. To ensure that this does not happen,
459464 autovacuum is invoked on any table that might contain unfrozen rows with
491496 normal delete and update activity is run in that window. Setting it too
492497 close could lead to anti-wraparound autovacuums, even though the table
493498 was recently vacuumed to reclaim space, whereas lower values lead to more
494- frequent whole-table scans .
499+ frequent aggressive vacuuming .
495500 </para>
496501
497502 <para>
527532 <structname>pg_database</>. In particular,
528533 the <structfield>relfrozenxid</> column of a table's
529534 <structname>pg_class</> row contains the freeze cutoff XID that was used
530- by the last whole-table <command>VACUUM</> for that table. All rows
535+ by the last aggressive <command>VACUUM</> for that table. All rows
531536 inserted by transactions with XIDs older than this cutoff XID are
532537 guaranteed to have been frozen. Similarly,
533538 the <structfield>datfrozenxid</> column of a database's
@@ -552,20 +557,23 @@ SELECT datname, age(datfrozenxid) FROM pg_database;
552557 </para>
553558
554559 <para>
555- <command>VACUUM</> normally
556- only scans pages that have been modified since the last vacuum, but
557- <structfield>relfrozenxid</> can only be advanced when the whole table is
558- scanned. The whole table is scanned when <structfield>relfrozenxid</> is
559- more than <varname>vacuum_freeze_table_age</> transactions old, when
560- <command>VACUUM</>'s <literal>FREEZE</> option is used, or when all pages
561- happen to
560+ <command>VACUUM</> normally only scans pages that have been modified
561+ since the last vacuum, but <structfield>relfrozenxid</> can only be
562+ advanced when every page of the table
563+ that might contain unfrozen XIDs is scanned. This happens when
564+ <structfield>relfrozenxid</> is more than
565+ <varname>vacuum_freeze_table_age</> transactions old, when
566+ <command>VACUUM</>'s <literal>FREEZE</> option is used, or when all
567+ pages that are not already all-frozen happen to
562568 require vacuuming to remove dead row versions. When <command>VACUUM</>
563- scans the whole table, after it's finished <literal>age(relfrozenxid)</>
564- should be a little more than the <varname>vacuum_freeze_min_age</> setting
565- that was used (more by the number of transactions started since the
566- <command>VACUUM</> started). If no whole-table-scanning <command>VACUUM</>
567- is issued on the table until <varname>autovacuum_freeze_max_age</> is
568- reached, an autovacuum will soon be forced for the table.
569+ scans every page in the table that is not already all-frozen, it should
570+ set <literal>age(relfrozenxid)</> to a value just a little more than the
571+ <varname>vacuum_freeze_min_age</> setting
572+ that was used (more by the number of transcations started since the
573+ <command>VACUUM</> started). If no <structfield>relfrozenxid</>-advancing
574+ <command>VACUUM</> is issued on the table until
575+ <varname>autovacuum_freeze_max_age</> is reached, an autovacuum will soon
576+ be forced for the table.
569577 </para>
570578
571579 <para>
@@ -634,35 +642,37 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
634642 </para>
635643
636644 <para>
637- During a <command>VACUUM</> table scan, either partial or of the whole
638- table, any multixact ID older than
645+ Whenever <command>VACUUM</> scans any part of a table, it will replace
646+ any multixact ID it encounters which is older than
639647 <xref linkend="guc-vacuum-multixact-freeze-min-age">
640- is replaced by a different value, which can be the zero value, a single
648+ by a different value, which can be the zero value, a single
641649 transaction ID, or a newer multixact ID. For each table,
642650 <structname>pg_class</>.<structfield>relminmxid</> stores the oldest
643651 possible multixact ID still appearing in any tuple of that table.
644652 If this value is older than
645- <xref linkend="guc-vacuum-multixact-freeze-table-age">, a whole-table
646- scan is forced. <function>mxid_age()</> can be used on
653+ <xref linkend="guc-vacuum-multixact-freeze-table-age">, an aggressive
654+ vacuum is forced. As discussed in the previous section, an aggressive
655+ vacuum means that only those pages which are known to be all-frozen will
656+ be skipped. <function>mxid_age()</> can be used on
647657 <structname>pg_class</>.<structfield>relminmxid</> to find its age.
648658 </para>
649659
650660 <para>
651- Whole-table <command>VACUUM</> scans, regardless of
661+ Aggressive <command>VACUUM</> scans, regardless of
652662 what causes them, enable advancing the value for that table.
653663 Eventually, as all tables in all databases are scanned and their
654664 oldest multixact values are advanced, on-disk storage for older
655665 multixacts can be removed.
656666 </para>
657667
658668 <para>
659- As a safety device, a whole-table vacuum scan will occur for any table
669+ As a safety device, an aggressive vacuum scan will occur for any table
660670 whose multixact-age is greater than
661- <xref linkend="guc-autovacuum-multixact-freeze-max-age">. Whole-table
671+ <xref linkend="guc-autovacuum-multixact-freeze-max-age">. Aggressive
662672 vacuum scans will also occur progressively for all tables, starting with
663673 those that have the oldest multixact-age, if the amount of used member
664674 storage space exceeds the amount 50% of the addressable storage space.
665- Both of these kinds of whole-table scans will occur even if autovacuum is
675+ Both of these kinds of aggressive scans will occur even if autovacuum is
666676 nominally disabled.
667677 </para>
668678 </sect3>
@@ -743,9 +753,9 @@ vacuum threshold = vacuum base threshold + vacuum scale factor * number of tuple
743753 <command>UPDATE</command> and <command>DELETE</command> operation. (It
744754 is only semi-accurate because some information might be lost under heavy
745755 load.) If the <structfield>relfrozenxid</> value of the table is more
746- than <varname>vacuum_freeze_table_age</> transactions old, the whole
747- table is scanned to freeze old tuples and advance
748- <structfield>relfrozenxid</>, otherwise only pages that have been modified
756+ than <varname>vacuum_freeze_table_age</> transactions old, an aggressive
757+ vacuum is performed to freeze old tuples and advance
758+ <structfield>relfrozenxid</>; otherwise, only pages that have been modified
749759 since the last vacuum are scanned.
750760 </para>
751761
0 commit comments