diff options
| author | Heikki Linnakangas | 2015-03-26 17:12:00 +0000 |
|---|---|---|
| committer | Heikki Linnakangas | 2015-03-26 17:12:00 +0000 |
| commit | d04c8ed9044eccebce043143a930617e3998c005 (patch) | |
| tree | e0167be995bb28dab91dfb92f1e18609e91a0d3e /src/include/access | |
| parent | 8fa393a6d739796d9f06a7fba91d7e1d0c354879 (diff) | |
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.
Diffstat (limited to 'src/include/access')
| -rw-r--r-- | src/include/access/genam.h | 2 | ||||
| -rw-r--r-- | src/include/access/gist.h | 3 | ||||
| -rw-r--r-- | src/include/access/gist_private.h | 9 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/include/access/genam.h b/src/include/access/genam.h index d1d624721db..d86590ac111 100644 --- a/src/include/access/genam.h +++ b/src/include/access/genam.h @@ -156,7 +156,7 @@ extern IndexBulkDeleteResult *index_bulk_delete(IndexVacuumInfo *info, void *callback_state); extern IndexBulkDeleteResult *index_vacuum_cleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats); -extern bool index_can_return(Relation indexRelation); +extern bool index_can_return(Relation indexRelation, int attno); extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum); extern FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum, diff --git a/src/include/access/gist.h b/src/include/access/gist.h index 01f0a70feee..50261b8bdd5 100644 --- a/src/include/access/gist.h +++ b/src/include/access/gist.h @@ -33,7 +33,8 @@ #define GIST_PICKSPLIT_PROC 6 #define GIST_EQUAL_PROC 7 #define GIST_DISTANCE_PROC 8 -#define GISTNProcs 8 +#define GIST_FETCH_PROC 9 +#define GISTNProcs 9 /* * strategy numbers for GiST opclasses that want to implement the old diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h index 95506879168..3693893e261 100644 --- a/src/include/access/gist_private.h +++ b/src/include/access/gist_private.h @@ -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, |
