From 48d4a8c88ba73c5e68461d1ced9090ac33827028 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Mon, 12 Apr 2021 09:03:16 +0530 Subject: [PATCH] Allocate access strategy in parallel VACUUM workers. Currently, parallel vacuum workers don't use any buffer access strategy. We can fix it either by propagating the access strategy from a leader or allow each worker to use BAS_VACUUM access strategy type. We don't see much use in propagating this information from leader as both leader and workers are supposed to use the same strategy. We might want to use a different access strategy for leader and workers but that would be a separate optimization not suitable for back-branches. This has been fixed in HEAD as commit f6b8f19a08. Author: Amit Kapila Reviewed-by: Sawada Masahiko, Bharath Rupireddy Discussion: https://postgr.es/m/CAA4eK1KbmJgRV2W3BbzRnKUSrukN7SbqBBriC4RDB5KBhopkGQ@mail.gmail.com --- src/backend/access/heap/vacuumlazy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index d6a8cf390c..fe2a6062b9 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -3510,6 +3510,9 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc) vac_open_indexes(onerel, RowExclusiveLock, &nindexes, &indrels); Assert(nindexes > 0); + /* Each parallel VACUUM worker gets its own access strategy */ + vac_strategy = GetAccessStrategy(BAS_VACUUM); + /* Set dead tuple space */ dead_tuples = (LVDeadTuples *) shm_toc_lookup(toc, PARALLEL_VACUUM_KEY_DEAD_TUPLES, @@ -3564,6 +3567,7 @@ parallel_vacuum_main(dsm_segment *seg, shm_toc *toc) vac_close_indexes(nindexes, indrels, RowExclusiveLock); table_close(onerel, ShareUpdateExclusiveLock); + FreeAccessStrategy(vac_strategy); pfree(stats); }