Skip to content

Commit 7cde6b1

Browse files
Adjust lazy_scan_heap() accounting comments.
Explain which particular LP_DEAD line pointers get accounted for by the tups_vacuumed variable.
1 parent f900a79 commit 7cde6b1

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/backend/access/heap/pruneheap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,12 @@ heap_page_prune_opt(Relation relation, Buffer buffer)
213213
* send its own new total to pgstats, and we don't want this delta applied
214214
* on top of that.)
215215
*
216+
* Sets latestRemovedXid for caller on return.
217+
*
216218
* off_loc is the offset location required by the caller to use in error
217219
* callback.
218220
*
219-
* Returns the number of tuples deleted from the page and sets
220-
* latestRemovedXid.
221+
* Returns the number of tuples deleted from the page during this call.
221222
*/
222223
int
223224
heap_page_prune(Relation relation, Buffer buffer,

src/backend/access/heap/vacuumlazy.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,9 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
765765
next_fsm_block_to_vacuum;
766766
double num_tuples, /* total number of nonremovable tuples */
767767
live_tuples, /* live tuples (reltuples estimate) */
768-
tups_vacuumed, /* tuples cleaned up by vacuum */
768+
tups_vacuumed, /* tuples cleaned up by current vacuum */
769769
nkeep, /* dead-but-not-removable tuples */
770-
nunused; /* unused line pointers */
770+
nunused; /* # existing unused line pointers */
771771
IndexBulkDeleteResult **indstats;
772772
int i;
773773
PGRUsage ru0;
@@ -1234,7 +1234,8 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
12341234
/*
12351235
* Prune all HOT-update chains in this page.
12361236
*
1237-
* We count tuples removed by the pruning step as removed by VACUUM.
1237+
* We count tuples removed by the pruning step as removed by VACUUM
1238+
* (existing LP_DEAD line pointers don't count).
12381239
*/
12391240
tups_vacuumed += heap_page_prune(onerel, buf, vistest, false,
12401241
InvalidTransactionId, 0,
@@ -1286,10 +1287,13 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
12861287
ItemPointerSet(&(tuple.t_self), blkno, offnum);
12871288

12881289
/*
1289-
* DEAD line pointers are to be vacuumed normally; but we don't
1290+
* LP_DEAD line pointers are to be vacuumed normally; but we don't
12901291
* count them in tups_vacuumed, else we'd be double-counting (at
12911292
* least in the common case where heap_page_prune() just freed up
1292-
* a non-HOT tuple).
1293+
* a non-HOT tuple). Note also that the final tups_vacuumed value
1294+
* might be very low for tables where opportunistic page pruning
1295+
* happens to occur very frequently (via heap_page_prune_opt()
1296+
* calls that free up non-HOT tuples).
12931297
*/
12941298
if (ItemIdIsDead(itemid))
12951299
{
@@ -1742,10 +1746,6 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats,
17421746
vacrelstats->relname,
17431747
tups_vacuumed, vacuumed_pages)));
17441748

1745-
/*
1746-
* This is pretty messy, but we split it up so that we can skip emitting
1747-
* individual parts of the message when not applicable.
1748-
*/
17491749
initStringInfo(&buf);
17501750
appendStringInfo(&buf,
17511751
_("%.0f dead row versions cannot be removed yet, oldest xmin: %u\n"),

0 commit comments

Comments
 (0)