diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2019-03-10 11:36:47 +0300 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2019-03-10 11:37:17 +0300 |
commit | f2e403803fe6deb8cff59ea09dff42c6163b2110 (patch) | |
tree | 1c3afef6e11f6498002b88219d9644e71bb5972d /src/backend/access/gist/gistsplit.c | |
parent | a0b762626884b3b949c2703abb1c4b42fbbdfdc6 (diff) | |
download | postgresql-f2e403803fe6deb8cff59ea09dff42c6163b2110.tar.gz postgresql-f2e403803fe6deb8cff59ea09dff42c6163b2110.zip |
Support for INCLUDE attributes in GiST indexes
Similarly to B-tree, GiST index access method gets support of INCLUDE
attributes. These attributes aren't used for tree navigation and aren't
present in non-leaf pages. But they are present in leaf pages and can be
fetched during index-only scan.
The point of having INCLUDE attributes in GiST indexes is slightly different
from the point of having them in B-tree. The main point of INCLUDE attributes
in B-tree is to define UNIQUE constraint over part of attributes enabled for
index-only scan. In GiST the main point of INCLUDE attributes is to use
index-only scan for attributes, whose data types don't have GiST opclasses.
Discussion: https://postgr.es/m/73A1A452-AD5F-40D4-BD61-978622FF75C1%40yandex-team.ru
Author: Andrey Borodin, with small changes by me
Reviewed-by: Andreas Karlsson
Diffstat (limited to 'src/backend/access/gist/gistsplit.c')
-rw-r--r-- | src/backend/access/gist/gistsplit.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/access/gist/gistsplit.c b/src/backend/access/gist/gistsplit.c index f210e0c39f4..6a9c54d86ce 100644 --- a/src/backend/access/gist/gistsplit.c +++ b/src/backend/access/gist/gistsplit.c @@ -207,7 +207,7 @@ placeOne(Relation r, GISTSTATE *giststate, GistSplitVector *v, gistDeCompressAtt(giststate, r, itup, NULL, (OffsetNumber) 0, identry, isnull); - for (; attno < giststate->tupdesc->natts; attno++) + for (; attno < giststate->nonLeafTupdesc->natts; attno++) { float lpenalty, rpenalty; @@ -485,7 +485,7 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec */ v->spl_dontcare = NULL; - if (attno + 1 < giststate->tupdesc->natts) + if (attno + 1 < giststate->nonLeafTupdesc->natts) { int NumDontCare; @@ -639,7 +639,7 @@ gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, Datum datum; bool IsNull; - datum = index_getattr(itup[i - 1], attno + 1, giststate->tupdesc, + datum = index_getattr(itup[i - 1], attno + 1, giststate->leafTupdesc, &IsNull); gistdentryinit(giststate, attno, &(entryvec->vector[i]), datum, r, page, i, @@ -657,7 +657,7 @@ gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, */ v->spl_risnull[attno] = v->spl_lisnull[attno] = true; - if (attno + 1 < giststate->tupdesc->natts) + if (attno + 1 < giststate->nonLeafTupdesc->natts) gistSplitByKey(r, page, itup, len, giststate, v, attno + 1); else gistSplitHalf(&v->splitVector, len); @@ -683,7 +683,7 @@ gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, v->splitVector.spl_left[v->splitVector.spl_nleft++] = i; /* Compute union keys, unless outer recursion level will handle it */ - if (attno == 0 && giststate->tupdesc->natts == 1) + if (attno == 0 && giststate->nonLeafTupdesc->natts == 1) { v->spl_dontcare = NULL; gistunionsubkey(giststate, itup, v); @@ -700,7 +700,7 @@ gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, * Splitting on attno column is not optimal, so consider * redistributing don't-care tuples according to the next column */ - Assert(attno + 1 < giststate->tupdesc->natts); + Assert(attno + 1 < giststate->nonLeafTupdesc->natts); if (v->spl_dontcare == NULL) { @@ -771,7 +771,7 @@ gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, * that PickSplit (or the special cases above) produced correct union * datums. */ - if (attno == 0 && giststate->tupdesc->natts > 1) + if (attno == 0 && giststate->nonLeafTupdesc->natts > 1) { v->spl_dontcare = NULL; gistunionsubkey(giststate, itup, v); |