diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index a09ceb2..2f72633 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -5984,12 +5984,15 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; - VACUUM performs a whole-table scan if the table's + VACUUM performs an aggressive scan if the table's pg_class.relfrozenxid field has reached - the age specified by this setting. The default is 150 million - transactions. Although users can set this value anywhere from zero to - two billions, VACUUM will silently limit the effective value - to 95% of , so that a + the age specified by this setting. An aggressive scan differs from + a regular VACUUM in that it visits every page that might + contain unfrozen XIDs or MXIDs, not just those that might contain dead + tuples. The default is 150 million transactions. Although users can + set this value anywhere from zero to two billions, VACUUM + will silently limit the effective value to 95% of + , so that a periodical manual VACUUM has a chance to run before an anti-wraparound autovacuum is launched for the table. For more information see @@ -6028,9 +6031,12 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; - VACUUM performs a whole-table scan if the table's + VACUUM performs an aggressive scan if the table's pg_class.relminmxid field has reached - the age specified by this setting. The default is 150 million multixacts. + the age specified by this setting. An aggressive scan differs from + a regular VACUUM in that it visits every page that might + contain unfrozen XIDs or MXIDs, not just those that might contain dead + tuples. The default is 150 million multixacts. Although users can set this value anywhere from zero to two billions, VACUUM will silently limit the effective value to 95% of , so that a diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml index 5204b34..d742ec9 100644 --- a/doc/src/sgml/maintenance.sgml +++ b/doc/src/sgml/maintenance.sgml @@ -438,22 +438,27 @@ - VACUUM normally skips pages that don't have any dead row - versions, but those pages might still have row versions with old XID - values. To ensure all old row versions have been frozen, a - scan of the whole table is needed. - controls when - VACUUM does that: a whole table sweep is forced if - the table hasn't been fully scanned for vacuum_freeze_table_age - minus vacuum_freeze_min_age transactions. Setting it to 0 - forces VACUUM to always scan all pages, effectively ignoring - the visibility map. + VACUUM uses the visibility map + to determine which pages of a relation must be scanned. Normally, it + will skips pages that don't have any dead row versions even if those pages + might still have row versions with old XID values. Therefore, normal + scans won't succeed in freezing every row version in the table. + Periodically, VACUUM will perform an aggressive + vacuum, skipping only those pages which contain neither dead rows nor + any unfrozen XID or MXID values. + + controls when VACUUM does that: all-visible but not all-frozen + pages are scanned if the number of transactions that have passed since the + last such scan is greater than vacuum_freeze_table_age minus + vacuum_freeze_min_age. Setting + vacuum_freeze_table_age to 0 forces VACUUM to + use this more aggressive strategy for all scans. The maximum time that a table can go unvacuumed is two billion transactions minus the vacuum_freeze_min_age value at - the time VACUUM last scanned the whole table. If it were to go + the time of the last aggressive vacuum. If it were to go unvacuumed for longer than that, data loss could result. To ensure that this does not happen, autovacuum is invoked on any table that might contain unfrozen rows with @@ -491,7 +496,7 @@ normal delete and update activity is run in that window. Setting it too close could lead to anti-wraparound autovacuums, even though the table was recently vacuumed to reclaim space, whereas lower values lead to more - frequent whole-table scans. + frequent aggressive vaccuuming. @@ -527,7 +532,7 @@ pg_database. In particular, the relfrozenxid column of a table's pg_class row contains the freeze cutoff XID that was used - by the last whole-table VACUUM for that table. All rows + by the last aggressive VACUUM for that table. All rows inserted by transactions with XIDs older than this cutoff XID are guaranteed to have been frozen. Similarly, the datfrozenxid column of a database's @@ -554,18 +559,21 @@ SELECT datname, age(datfrozenxid) FROM pg_database; VACUUM normally only scans pages that have been modified since the last vacuum, but - relfrozenxid can only be advanced when the whole table is - scanned. The whole table is scanned when relfrozenxid is - more than vacuum_freeze_table_age transactions old, when - VACUUM's FREEZE option is used, or when all pages - happen to + relfrozenxid can only be advanced every page of the table + that might contain unfrozen XIDs is scanned. This happens when + relfrozenxid is more than + vacuum_freeze_table_age transactions old, when + VACUUM's FREEZE option is used, or when all + pages that are not already all-frozen happen to require vacuuming to remove dead row versions. When VACUUM - scans the whole table, after it's finished age(relfrozenxid) - should be a little more than the vacuum_freeze_min_age setting + scans every page in the table that is not already all-frozen, it should + set age(relfrozenxid) to a value just a little more than the + vacuum_freeze_min_age setting that was used (more by the number of transactions started since the - VACUUM started). If no whole-table-scanning VACUUM - is issued on the table until autovacuum_freeze_max_age is - reached, an autovacuum will soon be forced for the table. + VACUUM started). If no relfrozenxid-advancing + VACUUM is issued on the table until + autovacuum_freeze_max_age is reached, an autovacuum will soon + be forced for the table. @@ -634,21 +642,23 @@ HINT: Stop the postmaster and vacuum that database in single-user mode. - During a VACUUM table scan, either partial or of the whole - table, any multixact ID older than + Whenever VACUUM scans any part of a table, it will replace + any multixact ID it encounters which is older than - is replaced by a different value, which can be the zero value, a single + by a different value, which can be the zero value, a single transaction ID, or a newer multixact ID. For each table, pg_class.relminmxid stores the oldest possible multixact ID still appearing in any tuple of that table. If this value is older than - , a whole-table - scan is forced. mxid_age() can be used on + , an aggressive + vacuum is forced. As discussed in the previous section, an aggressive + vacuum means that only those pages which are known to be all-frozen will + be skipped. mxid_age() can be used on pg_class.relminmxid to find its age. - Whole-table VACUUM scans, regardless of + Aggressive VACUUM scans, regardless of what causes them, enable advancing the value for that table. Eventually, as all tables in all databases are scanned and their oldest multixact values are advanced, on-disk storage for older @@ -656,13 +666,13 @@ HINT: Stop the postmaster and vacuum that database in single-user mode. - As a safety device, a whole-table vacuum scan will occur for any table + As a safety device, an aggressive vacuum scan will occur for any table whose multixact-age is greater than - . Whole-table + . Aggressive vacuum scans will also occur progressively for all tables, starting with those that have the oldest multixact-age, if the amount of used member storage space exceeds the amount 50% of the addressable storage space. - Both of these kinds of whole-table scans will occur even if autovacuum is + Both of these kinds of aggressive scans will occur even if autovacuum is nominally disabled. @@ -743,9 +753,9 @@ vacuum threshold = vacuum base threshold + vacuum scale factor * number of tuple UPDATE and DELETE operation. (It is only semi-accurate because some information might be lost under heavy load.) If the relfrozenxid value of the table is more - than vacuum_freeze_table_age transactions old, the whole - table is scanned to freeze old tuples and advance - relfrozenxid, otherwise only pages that have been modified + than vacuum_freeze_table_age transactions old, an aggressive + vacuum is performed to freeze old tuples and advance + relfrozenxid; otherwise, only pages that have been modified since the last vacuum are scanned.