From 5da264507058175e614f6ce7c77d2bd0491b1416 Mon Sep 17 00:00:00 2001 From: Claudio Freire Date: Mon, 24 Jul 2017 13:09:10 -0300 Subject: [PATCH] Vacuum FSM after each index pass This prevents concurrent writes from accumulating bloat due to recently freed space being invisible in the FSM yet. When vacuum can run for hours or days, this can make a huge difference. --- src/backend/commands/vacuumlazy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index fabb2f8d52..4d8d90e833 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -735,6 +735,9 @@ lazy_scan_heap(Relation onerel, int options, LVRelStats *vacrelstats, /* Remove tuples from heap */ lazy_vacuum_heap(onerel, vacrelstats); + /* Vacuum the Free Space Map */ + FreeSpaceMapVacuum(onerel); + /* * Forget the now-vacuumed tuples, and press on, but be careful * not to reset latestRemovedXid since we want that value to be -- 2.12.0