Skip to content

Commit 47029f7

Browse files
Remove unneeded old_rel_pages VACUUM state field.
The field hasn't been used since commit 3d351d9, which redefined pg_class.reltuples to be -1 before the first VACUUM or ANALYZE. Also rename a local variable of the same name ("old_rel_pages"). This is used by relation truncation to represent the original relation size at the start of the ongoing VACUUM operation. Rename it to orig_rel_pages, since that's a lot clearer. (This name matches similar nearby code.)
1 parent aec5cc9 commit 47029f7

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/backend/access/heap/vacuumlazy.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,10 @@ typedef struct LVRelState
323323
BufferAccessStrategy bstrategy;
324324
LVParallelState *lps;
325325

326-
/* Statistics from pg_class when we start out */
327-
BlockNumber old_rel_pages; /* previous value of pg_class.relpages */
328-
double old_live_tuples; /* previous value of pg_class.reltuples */
329326
/* rel's initial relfrozenxid and relminmxid */
330327
TransactionId relfrozenxid;
331328
MultiXactId relminmxid;
329+
double old_live_tuples; /* previous value of pg_class.reltuples */
332330

333331
/* VACUUM operation's cutoff for pruning */
334332
TransactionId OldestXmin;
@@ -593,10 +591,9 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
593591
}
594592

595593
vacrel->bstrategy = bstrategy;
596-
vacrel->old_rel_pages = rel->rd_rel->relpages;
597-
vacrel->old_live_tuples = rel->rd_rel->reltuples;
598594
vacrel->relfrozenxid = rel->rd_rel->relfrozenxid;
599595
vacrel->relminmxid = rel->rd_rel->relminmxid;
596+
vacrel->old_live_tuples = rel->rd_rel->reltuples;
600597

601598
/* Set cutoffs for entire VACUUM */
602599
vacrel->OldestXmin = OldestXmin;
@@ -3182,7 +3179,7 @@ should_attempt_truncation(LVRelState *vacrel)
31823179
static void
31833180
lazy_truncate_heap(LVRelState *vacrel)
31843181
{
3185-
BlockNumber old_rel_pages = vacrel->rel_pages;
3182+
BlockNumber orig_rel_pages = vacrel->rel_pages;
31863183
BlockNumber new_rel_pages;
31873184
bool lock_waiter_detected;
31883185
int lock_retry;
@@ -3246,7 +3243,7 @@ lazy_truncate_heap(LVRelState *vacrel)
32463243
* the newly added pages presumably contain non-deletable tuples.
32473244
*/
32483245
new_rel_pages = RelationGetNumberOfBlocks(vacrel->rel);
3249-
if (new_rel_pages != old_rel_pages)
3246+
if (new_rel_pages != orig_rel_pages)
32503247
{
32513248
/*
32523249
* Note: we intentionally don't update vacrel->rel_pages with the
@@ -3268,7 +3265,7 @@ lazy_truncate_heap(LVRelState *vacrel)
32683265
new_rel_pages = count_nondeletable_pages(vacrel, &lock_waiter_detected);
32693266
vacrel->blkno = new_rel_pages;
32703267

3271-
if (new_rel_pages >= old_rel_pages)
3268+
if (new_rel_pages >= orig_rel_pages)
32723269
{
32733270
/* can't do anything after all */
32743271
UnlockRelation(vacrel->rel, AccessExclusiveLock);
@@ -3294,16 +3291,16 @@ lazy_truncate_heap(LVRelState *vacrel)
32943291
* without also touching reltuples, since the tuple count wasn't
32953292
* changed by the truncation.
32963293
*/
3297-
vacrel->pages_removed += old_rel_pages - new_rel_pages;
3294+
vacrel->pages_removed += orig_rel_pages - new_rel_pages;
32983295
vacrel->rel_pages = new_rel_pages;
32993296

33003297
ereport(elevel,
33013298
(errmsg("\"%s\": truncated %u to %u pages",
33023299
vacrel->relname,
3303-
old_rel_pages, new_rel_pages),
3300+
orig_rel_pages, new_rel_pages),
33043301
errdetail_internal("%s",
33053302
pg_rusage_show(&ru0))));
3306-
old_rel_pages = new_rel_pages;
3303+
orig_rel_pages = new_rel_pages;
33073304
} while (new_rel_pages > vacrel->nonempty_pages && lock_waiter_detected);
33083305
}
33093306

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy