1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

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
This commit is contained in:
Heikki Linnakangas
2019-03-05 15:19:48 +02:00
parent 35bc0ec7c8
commit fe280694d0
2 changed files with 331 additions and 239 deletions

View File

@ -38,8 +38,8 @@ static bool gistinserttuples(GISTInsertState *state, GISTInsertStack *stack,
bool unlockbuf, bool unlockleftchild);
static void gistfinishsplit(GISTInsertState *state, GISTInsertStack *stack,
GISTSTATE *giststate, List *splitinfo, bool releasebuf);
static void gistvacuumpage(Relation rel, Page page, Buffer buffer,
Relation heapRel);
static void gistprunepage(Relation rel, Page page, Buffer buffer,
Relation heapRel);
#define ROTATEDIST(d) do { \
@ -261,7 +261,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
*/
if (is_split && GistPageIsLeaf(page) && GistPageHasGarbage(page))
{
gistvacuumpage(rel, page, buffer, heapRel);
gistprunepage(rel, page, buffer, heapRel);
is_split = gistnospace(page, itup, ntup, oldoffnum, freespace);
}
@ -1544,11 +1544,11 @@ freeGISTstate(GISTSTATE *giststate)
}
/*
* gistvacuumpage() -- try to remove LP_DEAD items from the given page.
* gistprunepage() -- try to remove LP_DEAD items from the given page.
* Function assumes that buffer is exclusively locked.
*/
static void
gistvacuumpage(Relation rel, Page page, Buffer buffer, Relation heapRel)
gistprunepage(Relation rel, Page page, Buffer buffer, Relation heapRel)
{
OffsetNumber deletable[MaxIndexTuplesPerPage];
int ndeletable = 0;