Index FSMs needs to be vacuumed as well. Report by Jeff Davis.
authorHeikki Linnakangas <heikki@enterprisedb.com>
Mon, 6 Oct 2008 08:04:11 +0000 (08:04 +0000)
committerHeikki Linnakangas <heikki@enterprisedb.com>
Mon, 6 Oct 2008 08:04:11 +0000 (08:04 +0000)
src/backend/access/gin/ginvacuum.c
src/backend/access/gist/gistvacuum.c
src/backend/access/nbtree/nbtree.c
src/backend/storage/freespace/indexfsm.c
src/include/storage/indexfsm.h

index 41db05c62eeec3cb5a71aedb4644cf0ad9faaa84..a0fa4cafe778b0a0d7e6e73921d4e3a945c119c3 100644 (file)
@@ -744,6 +744,9 @@ ginvacuumcleanup(PG_FUNCTION_ARGS)
                totFreePages = totFreePages - stats->pages_removed;
        }
 
+       /* Finally, vacuum the FSM */
+       IndexFreeSpaceMapVacuum(info->index);
+
        stats->pages_free = totFreePages;
 
        if (needLock)
index e9004e8969350125bc75aaff9d72fa3a9069a227..f83f2a40cb30d5f6db4d93632a63cf67d90f1624 100644 (file)
@@ -619,6 +619,9 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
                totFreePages = totFreePages - stats->std.pages_removed;
        }
 
+       /* Finally, vacuum the FSM */
+       IndexFreeSpaceMapVacuum(info->index);
+
        /* return statistics */
        stats->std.pages_free = totFreePages;
        if (needLock)
index aacb35d4656c4b7fc9038f4026ee0d7fcf865b17..a7156823d35700f0d36b981262cfdd169fa28da0 100644 (file)
@@ -574,6 +574,9 @@ btvacuumcleanup(PG_FUNCTION_ARGS)
                btvacuumscan(info, stats, NULL, NULL, 0);
        }
 
+       /* Finally, vacuum the FSM */
+       IndexFreeSpaceMapVacuum(info->index);
+
        /*
         * During a non-FULL vacuum it's quite possible for us to be fooled by
         * concurrent page splits into double-counting some index tuples, so
index fa0f4f118b4bc2758c0e8cfb4bc25b65e6c66670..7e33879682d026c74777c9944562fadbde51852d 100644 (file)
@@ -90,3 +90,12 @@ IndexFreeSpaceMapTruncate(Relation rel, BlockNumber nblocks)
 {
        FreeSpaceMapTruncateRel(rel, nblocks);
 }
+
+/*
+ * IndexFreeSpaceMapVacuum - scan and fix any inconsistencies in the FSM
+ */
+void
+IndexFreeSpaceMapVacuum(Relation rel)
+{
+       FreeSpaceMapVacuum(rel);
+}
index 179d2f1367c677dd912b7df9a570d24d27ecd028..53e7b2025f085f15919ef6ba00a077bbb6a0dc60 100644 (file)
 
 #include "utils/rel.h"
 
-extern void InitIndexFreeSpaceMap(Relation rel);
-
 extern BlockNumber GetFreeIndexPage(Relation rel);
 extern void RecordFreeIndexPage(Relation rel, BlockNumber page);
 extern void RecordUsedIndexPage(Relation rel, BlockNumber page);
 
+extern void InitIndexFreeSpaceMap(Relation rel);
 extern void IndexFreeSpaceMapTruncate(Relation rel, BlockNumber nblocks);
+extern void IndexFreeSpaceMapVacuum(Relation rel);
 
 #endif   /* INDEXFSM_H */