Skip to content

Commit fe28069

Browse files
committed
Scan GiST indexes in physical order during VACUUM.
Scanning an index in physical order is faster than walking it in logical order, because sequential I/O is faster than random I/O. The idea and code structure is borrowed from B-tree vacuum code. Patch by Andrey Borodin, with changes by me. Based on early work by Konstantin Kuznetsov, although the patch has been rewritten multiple times since his original version. Discussion: https://www.postgresql.org/message-id/1B9FAC6F-FA19-4A24-8C1B-F4F574844892%40yandex-team.ru
1 parent 35bc0ec commit fe28069

File tree

2 files changed

+287
-195
lines changed

2 files changed

+287
-195
lines changed

src/backend/access/gist/gist.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ static bool gistinserttuples(GISTInsertState *state, GISTInsertStack *stack,
3838
bool unlockbuf, bool unlockleftchild);
3939
static void gistfinishsplit(GISTInsertState *state, GISTInsertStack *stack,
4040
GISTSTATE *giststate, List *splitinfo, bool releasebuf);
41-
static void gistvacuumpage(Relation rel, Page page, Buffer buffer,
42-
Relation heapRel);
41+
static void gistprunepage(Relation rel, Page page, Buffer buffer,
42+
Relation heapRel);
4343

4444

4545
#define ROTATEDIST(d) do { \
@@ -261,7 +261,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
261261
*/
262262
if (is_split && GistPageIsLeaf(page) && GistPageHasGarbage(page))
263263
{
264-
gistvacuumpage(rel, page, buffer, heapRel);
264+
gistprunepage(rel, page, buffer, heapRel);
265265
is_split = gistnospace(page, itup, ntup, oldoffnum, freespace);
266266
}
267267

@@ -1544,11 +1544,11 @@ freeGISTstate(GISTSTATE *giststate)
15441544
}
15451545

15461546
/*
1547-
* gistvacuumpage() -- try to remove LP_DEAD items from the given page.
1547+
* gistprunepage() -- try to remove LP_DEAD items from the given page.
15481548
* Function assumes that buffer is exclusively locked.
15491549
*/
15501550
static void
1551-
gistvacuumpage(Relation rel, Page page, Buffer buffer, Relation heapRel)
1551+
gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
15521552
{
15531553
OffsetNumber deletable[MaxIndexTuplesPerPage];
15541554
int ndeletable = 0;

0 commit comments

Comments
 (0)