1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-17 17:02:08 +03:00

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
This commit is contained in:
Alexander Korotkov
2019-03-10 11:36:47 +03:00
parent a0b7626268
commit f2e403803f
16 changed files with 382 additions and 48 deletions

View File

@ -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);