Skip to content

Commit 89f373b

Browse files
committed
Index FSMs needs to be vacuumed as well. Report by Jeff Davis.
1 parent 557faa4 commit 89f373b

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

src/backend/access/gin/ginvacuum.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.22 2008/09/30 10:52:10 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.23 2008/10/06 08:04:11 heikki Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414

@@ -744,6 +744,9 @@ ginvacuumcleanup(PG_FUNCTION_ARGS)
744744
totFreePages = totFreePages - stats->pages_removed;
745745
}
746746

747+
/* Finally, vacuum the FSM */
748+
IndexFreeSpaceMapVacuum(info->index);
749+
747750
stats->pages_free = totFreePages;
748751

749752
if (needLock)

src/backend/access/gist/gistvacuum.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.37 2008/09/30 10:52:10 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.38 2008/10/06 08:04:11 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -619,6 +619,9 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
619619
totFreePages = totFreePages - stats->std.pages_removed;
620620
}
621621

622+
/* Finally, vacuum the FSM */
623+
IndexFreeSpaceMapVacuum(info->index);
624+
622625
/* return statistics */
623626
stats->std.pages_free = totFreePages;
624627
if (needLock)

src/backend/access/nbtree/nbtree.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.162 2008/09/30 10:52:10 heikki Exp $
15+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.163 2008/10/06 08:04:11 heikki Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -574,6 +574,9 @@ btvacuumcleanup(PG_FUNCTION_ARGS)
574574
btvacuumscan(info, stats, NULL, NULL, 0);
575575
}
576576

577+
/* Finally, vacuum the FSM */
578+
IndexFreeSpaceMapVacuum(info->index);
579+
577580
/*
578581
* During a non-FULL vacuum it's quite possible for us to be fooled by
579582
* concurrent page splits into double-counting some index tuples, so

src/backend/storage/freespace/indexfsm.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/freespace/indexfsm.c,v 1.1 2008/09/30 10:52:13 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/freespace/indexfsm.c,v 1.2 2008/10/06 08:04:11 heikki Exp $
1212
*
1313
*
1414
* NOTES:
@@ -90,3 +90,12 @@ IndexFreeSpaceMapTruncate(Relation rel, BlockNumber nblocks)
9090
{
9191
FreeSpaceMapTruncateRel(rel, nblocks);
9292
}
93+
94+
/*
95+
* IndexFreeSpaceMapVacuum - scan and fix any inconsistencies in the FSM
96+
*/
97+
void
98+
IndexFreeSpaceMapVacuum(Relation rel)
99+
{
100+
FreeSpaceMapVacuum(rel);
101+
}

src/include/storage/indexfsm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/storage/indexfsm.h,v 1.1 2008/09/30 10:52:14 heikki Exp $
10+
* $PostgreSQL: pgsql/src/include/storage/indexfsm.h,v 1.2 2008/10/06 08:04:11 heikki Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -16,12 +16,12 @@
1616

1717
#include "utils/rel.h"
1818

19-
extern void InitIndexFreeSpaceMap(Relation rel);
20-
2119
extern BlockNumber GetFreeIndexPage(Relation rel);
2220
extern void RecordFreeIndexPage(Relation rel, BlockNumber page);
2321
extern void RecordUsedIndexPage(Relation rel, BlockNumber page);
2422

23+
extern void InitIndexFreeSpaceMap(Relation rel);
2524
extern void IndexFreeSpaceMapTruncate(Relation rel, BlockNumber nblocks);
25+
extern void IndexFreeSpaceMapVacuum(Relation rel);
2626

2727
#endif /* INDEXFSM_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy