Index FSMs needs to be vacuumed as well. Report by Jeff Davis.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 6 Oct 2008 08:04:11 +0000 (08:04 +0000)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
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 c3e6f4e6f2d421856c3f018b4ae2f7c91d820417..733710ef563127cac89547e955f793fb2c48d414 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *                     $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.22 2008/09/30 10:52:10 heikki Exp $
+ *                     $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.23 2008/10/06 08:04:11 heikki Exp $
  *-------------------------------------------------------------------------
  */
 
@@ -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 b545922ccc8c2d2a7391cb23cb5ec6d8c7f92166..2a917b6528aadbe8c3c8ad4040a254686a6f5d22 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.37 2008/09/30 10:52:10 heikki Exp $
+ *       $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.38 2008/10/06 08:04:11 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 abb6bd5c5d4990307933390ef091fbd217044daf..76f6a472aefc412d46ae9455734e9e190639f5f0 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.162 2008/09/30 10:52:10 heikki Exp $
+ *       $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.163 2008/10/06 08:04:11 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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 62fd3d3794203470b6499b24d5510f83e31e3871..768b633f0819fd3c310acb1ceaadee36cc556c6a 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/storage/freespace/indexfsm.c,v 1.1 2008/09/30 10:52:13 heikki Exp $
+ *       $PostgreSQL: pgsql/src/backend/storage/freespace/indexfsm.c,v 1.2 2008/10/06 08:04:11 heikki Exp $
  *
  *
  * NOTES:
@@ -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 76bb26f7bc87041c35a33ae7fa26cecf2be0279d..36872076f87b72b3c2ed6c4d997e41fb006a8743 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/indexfsm.h,v 1.1 2008/09/30 10:52:14 heikki Exp $
+ * $PostgreSQL: pgsql/src/include/storage/indexfsm.h,v 1.2 2008/10/06 08:04:11 heikki Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #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 */