mirror of
https://github.com/postgres/postgres.git
synced 2025-08-24 09:27:52 +03:00
Add support for index-only scans in GiST.
This adds a new GiST opclass method, 'fetch', which is used to reconstruct the original Datum from the value stored in the index. Also, the 'canreturn' index AM interface function gains a new 'attno' argument. That makes it possible to use index-only scans on a multi-column index where some of the opclasses support index-only scans but some do not. This patch adds support in the box and point opclasses. Other opclasses can added later as follow-on patches (btree_gist would be particularly interesting). Anastasia Lubennikova, with additional fixes and modifications by me.
This commit is contained in:
@@ -87,6 +87,7 @@ typedef struct GISTSTATE
|
||||
FmgrInfo picksplitFn[INDEX_MAX_KEYS];
|
||||
FmgrInfo equalFn[INDEX_MAX_KEYS];
|
||||
FmgrInfo distanceFn[INDEX_MAX_KEYS];
|
||||
FmgrInfo fetchFn[INDEX_MAX_KEYS];
|
||||
|
||||
/* Collations to pass to the support functions */
|
||||
Oid supportCollation[INDEX_MAX_KEYS];
|
||||
@@ -118,6 +119,8 @@ typedef struct GISTSearchHeapItem
|
||||
{
|
||||
ItemPointerData heapPtr;
|
||||
bool recheck; /* T if quals must be rechecked */
|
||||
IndexTuple ftup; /* data fetched back from the index, used in
|
||||
* index-only scans */
|
||||
} GISTSearchHeapItem;
|
||||
|
||||
/* Unvisited item, either index page or heap tuple */
|
||||
@@ -157,6 +160,8 @@ typedef struct GISTScanOpaqueData
|
||||
GISTSearchHeapItem pageData[BLCKSZ / sizeof(IndexTupleData)];
|
||||
OffsetNumber nPageData; /* number of valid items in array */
|
||||
OffsetNumber curPageData; /* next item to return */
|
||||
MemoryContext pageDataCxt; /* context holding the fetched tuples, for
|
||||
index-only scans */
|
||||
} GISTScanOpaqueData;
|
||||
|
||||
typedef GISTScanOpaqueData *GISTScanOpaque;
|
||||
@@ -409,6 +414,7 @@ typedef struct GiSTOptions
|
||||
/* gist.c */
|
||||
extern Datum gistbuildempty(PG_FUNCTION_ARGS);
|
||||
extern Datum gistinsert(PG_FUNCTION_ARGS);
|
||||
extern Datum gistcanreturn(PG_FUNCTION_ARGS);
|
||||
extern MemoryContext createTempGistContext(void);
|
||||
extern GISTSTATE *initGISTstate(Relation index);
|
||||
extern void freeGISTstate(GISTSTATE *giststate);
|
||||
@@ -504,7 +510,8 @@ extern void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len,
|
||||
extern bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b);
|
||||
extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
|
||||
OffsetNumber o, GISTENTRY *attdata, bool *isnull);
|
||||
|
||||
extern IndexTuple gistFetchTuple(GISTSTATE *giststate, Relation r,
|
||||
IndexTuple tuple);
|
||||
extern void gistMakeUnionKey(GISTSTATE *giststate, int attno,
|
||||
GISTENTRY *entry1, bool isnull1,
|
||||
GISTENTRY *entry2, bool isnull2,
|
||||
|
Reference in New Issue
Block a user