From 013ebc0a7b7ea9c1b1ab7a3d4dd75ea121ea8ba7 Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Wed, 9 Sep 2015 18:43:37 +0300 Subject: Microvacuum for GIST Mark index tuple as dead if it's pointed by kill_prior_tuple during ordinary (search) scan and remove it during insert process if there is no enough space for new tuple to insert. This improves select performance because index will not return tuple marked as dead and improves insert performance because it reduces number of page split. Anastasia Lubennikova with minor editorialization by me --- src/include/access/gist_private.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/include/access/gist_private.h') diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h index 4f1a5c33ea..1a77982391 100644 --- a/src/include/access/gist_private.h +++ b/src/include/access/gist_private.h @@ -22,6 +22,7 @@ #include "storage/bufmgr.h" #include "storage/buffile.h" #include "utils/hsearch.h" +#include "access/genam.h" /* * Maximum number of "halves" a page can be split into in one operation. @@ -121,9 +122,11 @@ typedef struct GISTSearchHeapItem { ItemPointerData heapPtr; bool recheck; /* T if quals must be rechecked */ - bool recheckDistances; /* T if distances must be rechecked */ + bool recheckDistances; /* T if distances must be rechecked */ IndexTuple ftup; /* data fetched back from the index, used in * index-only scans */ + OffsetNumber offnum; /* track offset in page to mark tuple as + * LP_DEAD */ } GISTSearchHeapItem; /* Unvisited item, either index page or heap tuple */ @@ -161,6 +164,12 @@ typedef struct GISTScanOpaqueData /* pre-allocated workspace arrays */ double *distances; /* output area for gistindex_keytest */ + /* info about killed items if any (killedItems is NULL if never used) */ + OffsetNumber *killedItems; /* offset numbers of killed items */ + int numKilled; /* number of currently stored items */ + BlockNumber curBlkno; /* current number of block */ + GistNSN curPageLSN; /* pos in the WAL stream when page was read */ + /* In a non-ordered search, returnable heap items are stored here: */ GISTSearchHeapItem pageData[BLCKSZ / sizeof(IndexTupleData)]; OffsetNumber nPageData; /* number of valid items in array */ -- cgit v1.2.1