aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistvacuum.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/gist/gistvacuum.c')
-rw-r--r--src/backend/access/gist/gistvacuum.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/backend/access/gist/gistvacuum.c b/src/backend/access/gist/gistvacuum.c
index 1c4e2c19b76..14202fa25ed 100644
--- a/src/backend/access/gist/gistvacuum.c
+++ b/src/backend/access/gist/gistvacuum.c
@@ -34,6 +34,7 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
BlockNumber npages,
blkno;
BlockNumber totFreePages;
+ double tuplesCount;
bool needLock;
/* No-op in ANALYZE ONLY mode */
@@ -42,17 +43,7 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
/* Set up all-zero stats if gistbulkdelete wasn't called */
if (stats == NULL)
- {
stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult));
- /* use heap's tuple count */
- stats->num_index_tuples = info->num_heap_tuples;
- stats->estimated_count = info->estimated_count;
-
- /*
- * XXX the above is wrong if index is partial. Would it be OK to just
- * return NULL, or is there work we must do below?
- */
- }
/*
* Need lock unless it's local to this backend.
@@ -67,6 +58,7 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
UnlockRelationForExtension(rel, ExclusiveLock);
totFreePages = 0;
+ tuplesCount = 0;
for (blkno = GIST_ROOT_BLKNO + 1; blkno < npages; blkno++)
{
Buffer buffer;
@@ -84,6 +76,11 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
totFreePages++;
RecordFreeIndexPage(rel, blkno);
}
+ else if (GistPageIsLeaf(page))
+ {
+ /* count tuples in index (considering only leaf tuples) */
+ tuplesCount += PageGetMaxOffsetNumber(page);
+ }
UnlockReleaseBuffer(buffer);
}
@@ -97,6 +94,8 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
stats->num_pages = RelationGetNumberOfBlocks(rel);
if (needLock)
UnlockRelationForExtension(rel, ExclusiveLock);
+ stats->num_index_tuples = tuplesCount;
+ stats->estimated_count = false;
PG_RETURN_POINTER(stats);
}