From a6359a3227d55cf68a9cfd137baad394137536c6 Mon Sep 17 00:00:00 2001 From: Masahiko Sawada Date: Mon, 25 Jan 2021 16:20:37 +0900 Subject: [PATCH v3 3/3] PoC: disable index cleanup when an anti-wraparound and aggressive vacuum. --- src/backend/access/heap/vacuumlazy.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index b99b7e51f4..8ed8a17ec2 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -529,6 +529,23 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, if (params->options & VACOPT_DISABLE_PAGE_SKIPPING) aggressive = true; + /* + * If the vacuum is initiated to prevent xid-wraparound and is an aggressive + * scan, we disable index cleanup to make freezing heap tuples and moving + * relfrozenxid forward complete faster. + * + * Note that this applies only autovacuums as is_wraparound can be true + * in autovacuums. + * + * XXX: should we not disable index cleanup if vacuum_index_cleanup reloption + * is on? + */ + if (aggressive && params->is_wraparound) + { + Assert(IsAutoVacuumWorkerProcess()); + params->index_cleanup = VACOPT_TERNARY_DISABLED; + } + vacrelstats = (LVRelStats *) palloc0(sizeof(LVRelStats)); vacrelstats->relnamespace = get_namespace_name(RelationGetNamespace(onerel)); -- 2.27.0