aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Geoghegan <pg@bowt.ie>2021-02-14 19:28:37 -0800
committerPeter Geoghegan <pg@bowt.ie>2021-02-14 19:28:37 -0800
commit7cde6b13a9b630e2f04d91e2f17dedc2afee21c6 (patch)
treeba66e8f40ff0fd4866cb034888fdca3bbee1c330 /src
parentf900a79ecdc1864a6ead72c97c34a41012227eaf (diff)
downloadpostgresql-7cde6b13a9b630e2f04d91e2f17dedc2afee21c6.tar.gz
postgresql-7cde6b13a9b630e2f04d91e2f17dedc2afee21c6.zip
Adjust lazy_scan_heap() accounting comments.
Explain which particular LP_DEAD line pointers get accounted for by the tups_vacuumed variable.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/heap/pruneheap.c5
-rw-r--r--src/backend/access/heap/vacuumlazy.c18
2 files changed, 12 insertions, 11 deletions
diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index e3a716a2a2f..8bb38d6406e 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -213,11 +213,12 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
* send its own new total to pgstats, and we don't want this delta applied
* on top of that.)
*
+ * Sets latestRemovedXid for caller on return.
+ *
* off_loc is the offset location required by the caller to use in error
* callback.
*
- * Returns the number of tuples deleted from the page and sets
- * latestRemovedXid.
+ * Returns the number of tuples deleted from the page during this call.
*/
int
heap_page_prune(Relation relation, Buffer buffer,
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index f3d2265fad7..e9bd6dba80f 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -765,9 +765,9 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
next_fsm_block_to_vacuum;
double num_tuples, /* total number of nonremovable tuples */
live_tuples, /* live tuples (reltuples estimate) */
- tups_vacuumed, /* tuples cleaned up by vacuum */
+ tups_vacuumed, /* tuples cleaned up by current vacuum */
nkeep, /* dead-but-not-removable tuples */
- nunused; /* unused line pointers */
+ nunused; /* # existing unused line pointers */
IndexBulkDeleteResult **indstats;
int i;
PGRUsage ru0;
@@ -1234,7 +1234,8 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
/*
* Prune all HOT-update chains in this page.
*
- * We count tuples removed by the pruning step as removed by VACUUM.
+ * We count tuples removed by the pruning step as removed by VACUUM
+ * (existing LP_DEAD line pointers don't count).
*/
tups_vacuumed += heap_page_prune(onerel, buf, vistest, false,
InvalidTransactionId, 0,
@@ -1286,10 +1287,13 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
ItemPointerSet(&(tuple.t_self), blkno, offnum);
/*
- * DEAD line pointers are to be vacuumed normally; but we don't
+ * LP_DEAD line pointers are to be vacuumed normally; but we don't
* count them in tups_vacuumed, else we'd be double-counting (at
* least in the common case where heap_page_prune() just freed up
- * a non-HOT tuple).
+ * a non-HOT tuple). Note also that the final tups_vacuumed value
+ * might be very low for tables where opportunistic page pruning
+ * happens to occur very frequently (via heap_page_prune_opt()
+ * calls that free up non-HOT tuples).
*/
if (ItemIdIsDead(itemid))
{
@@ -1742,10 +1746,6 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
vacrelstats->relname,
tups_vacuumed, vacuumed_pages)));
- /*
- * This is pretty messy, but we split it up so that we can skip emitting
- * individual parts of the message when not applicable.
- */
initStringInfo(&buf);
appendStringInfo(&buf,
_("%.0f dead row versions cannot be removed yet, oldest xmin: %u\n"),