mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Add relallfrozen to pg_class
Add relallfrozen, an estimate of the number of pages marked all-frozen in the visibility map. pg_class already has relallvisible, an estimate of the number of pages in the relation marked all-visible in the visibility map. This is used primarily for planning. relallfrozen, together with relallvisible, is useful for estimating the outstanding number of all-visible but not all-frozen pages in the relation for the purposes of scheduling manual VACUUMs and tuning vacuum freeze parameters. A future commit will use relallfrozen to trigger more frequent vacuums on insert-focused workloads with significant volume of frozen data. Bump catalog version Author: Melanie Plageman <melanieplageman@gmail.com> Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Robert Treat <rob@xzilla.net> Reviewed-by: Corey Huinker <corey.huinker@gmail.com> Reviewed-by: Greg Sabino Mullane <htamfids@gmail.com> Discussion: https://postgr.es/m/flat/CAAKRu_aj-P7YyBz_cPNwztz6ohP%2BvWis%3Diz3YcomkB3NpYA--w%40mail.gmail.com
This commit is contained in:
@@ -623,7 +623,8 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
|
||||
minmulti_updated;
|
||||
BlockNumber orig_rel_pages,
|
||||
new_rel_pages,
|
||||
new_rel_allvisible;
|
||||
new_rel_allvisible,
|
||||
new_rel_allfrozen;
|
||||
PGRUsage ru0;
|
||||
TimestampTz starttime = 0;
|
||||
PgStat_Counter startreadtime = 0,
|
||||
@@ -898,10 +899,18 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
|
||||
* pg_class.relpages to
|
||||
*/
|
||||
new_rel_pages = vacrel->rel_pages; /* After possible rel truncation */
|
||||
visibilitymap_count(rel, &new_rel_allvisible, NULL);
|
||||
visibilitymap_count(rel, &new_rel_allvisible, &new_rel_allfrozen);
|
||||
if (new_rel_allvisible > new_rel_pages)
|
||||
new_rel_allvisible = new_rel_pages;
|
||||
|
||||
/*
|
||||
* An all-frozen block _must_ be all-visible. As such, clamp the count of
|
||||
* all-frozen blocks to the count of all-visible blocks. This matches the
|
||||
* clamping of relallvisible above.
|
||||
*/
|
||||
if (new_rel_allfrozen > new_rel_allvisible)
|
||||
new_rel_allfrozen = new_rel_allvisible;
|
||||
|
||||
/*
|
||||
* Now actually update rel's pg_class entry.
|
||||
*
|
||||
@@ -910,7 +919,8 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
|
||||
* scan every page that isn't skipped using the visibility map.
|
||||
*/
|
||||
vac_update_relstats(rel, new_rel_pages, vacrel->new_live_tuples,
|
||||
new_rel_allvisible, vacrel->nindexes > 0,
|
||||
new_rel_allvisible, new_rel_allfrozen,
|
||||
vacrel->nindexes > 0,
|
||||
vacrel->NewRelfrozenXid, vacrel->NewRelminMxid,
|
||||
&frozenxid_updated, &minmulti_updated, false);
|
||||
|
||||
@@ -3720,7 +3730,7 @@ update_relstats_all_indexes(LVRelState *vacrel)
|
||||
vac_update_relstats(indrel,
|
||||
istat->num_pages,
|
||||
istat->num_index_tuples,
|
||||
0,
|
||||
0, 0,
|
||||
false,
|
||||
InvalidTransactionId,
|
||||
InvalidMultiXactId,
|
||||
|
||||
Reference in New Issue
Block a user