public inbox for [email protected]
help / color / mirror / Atom feedFrom: Heikki Linnakangas <[email protected]>
Subject: [PATCH 5/6] Remove 'numEmptyPages'. it's not really needed.
Date: Mon, 11 Mar 2019 15:41:07 +0200
---
src/backend/access/gist/gistvacuum.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/backend/access/gist/gistvacuum.c b/src/backend/access/gist/gistvacuum.c
index b95e755406e..bf0b9d54f69 100644
--- a/src/backend/access/gist/gistvacuum.c
+++ b/src/backend/access/gist/gistvacuum.c
@@ -28,7 +28,6 @@ typedef struct
IndexBulkDeleteResult stats;
IndexVacuumInfo *info;
- BlockNumber numEmptyPages;
BlockSet internalPagesMap;
BlockSet emptyLeafPagesMap;
} GistBulkDeleteResult;
@@ -349,7 +348,6 @@ restart:
if (nremain == 0)
{
stats->emptyLeafPagesMap = blockset_set(stats->emptyLeafPagesMap, blkno);
- stats->numEmptyPages++;
}
else
stats->stats.num_index_tuples += nremain;
@@ -408,13 +406,15 @@ gistvacuum_recycle_pages(GistBulkDeleteResult *stats)
BlockNumber x;
/* quick exit if no empty pages */
- if (stats->numEmptyPages > 0)
- gistvacuum_recycle_pages(stats);
+ /* HEIKKI: I'm assuming the blockset is always NULL if it's empty. That's true
+ * for the current usage. But add comments, and maybe a blockset_isempty() macro
+ * for clarity */
+ if (stats->emptyLeafPagesMap == NULL)
+ return;
/* rescan all inner pages to find those that have empty child pages */
x = InvalidBlockNumber;
- while (stats->numEmptyPages > 0 &&
- (x = blockset_next(stats->internalPagesMap, x)) != InvalidBlockNumber)
+ while ((x = blockset_next(stats->internalPagesMap, x)) != InvalidBlockNumber)
{
Buffer buffer;
Page page;
@@ -442,7 +442,9 @@ gistvacuum_recycle_pages(GistBulkDeleteResult *stats)
maxoff = PageGetMaxOffsetNumber(page);
/* Check that leafs are still empty and decide what to delete */
- for (off = FirstOffsetNumber; off <= maxoff && ntodelete < maxoff-1; off = OffsetNumberNext(off))
+ for (off = FirstOffsetNumber;
+ off <= maxoff && ntodelete < maxoff-1;
+ off = OffsetNumberNext(off))
{
Buffer leafBuffer;
Page leafPage;
@@ -569,7 +571,6 @@ gistvacuum_recycle_pages(GistBulkDeleteResult *stats)
GistPageSetDeleted(leafPage);
MarkBufferDirty(buftodelete[i]);
stats->stats.pages_deleted++;
- stats->numEmptyPages--;
MarkBufferDirty(buffer);
/* Offsets are changed as long as we delete tuples from internal page */
--
2.20.1
--------------AF9416BC788B4CF5E4BF929D
Content-Type: text/x-patch;
name="0006-Misc-cleanup.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="0006-Misc-cleanup.patch"
view thread (16+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH 5/6] Remove 'numEmptyPages'. it's not really needed.
In-Reply-To: <no-message-id-1883630@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox