diff options
Diffstat (limited to 'src/include/access')
-rw-r--r-- | src/include/access/gist.h | 29 | ||||
-rw-r--r-- | src/include/access/gist_private.h | 13 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/include/access/gist.h b/src/include/access/gist.h index ed57bb7f93a..8ee0fdf53fc 100644 --- a/src/include/access/gist.h +++ b/src/include/access/gist.h @@ -85,11 +85,30 @@ typedef GISTPageOpaqueData *GISTPageOpaque; /* * This is the Split Vector to be returned by the PickSplit method. - * PickSplit should check spl_(r|l)datum_exists. If it is 'true', - * that corresponding spl_(r|l)datum already defined and - * PickSplit should use that value. PickSplit should always set - * spl_(r|l)datum_exists to false: GiST will check value to - * control supporting this feature by PickSplit... + * PickSplit should fill the indexes of tuples to go to the left side into + * spl_left[], and those to go to the right into spl_right[] (note the method + * is responsible for palloc'ing both of these arrays!). The tuple counts + * go into spl_nleft/spl_nright, and spl_ldatum/spl_rdatum must be set to + * the union keys for each side. + * + * If spl_ldatum_exists and spl_rdatum_exists are true, then we are performing + * a "secondary split" using a non-first index column. In this case some + * decisions have already been made about a page split, and the set of tuples + * being passed to PickSplit is just the tuples about which we are undecided. + * spl_ldatum/spl_rdatum then contain the union keys for the tuples already + * chosen to go left or right. Ideally the PickSplit method should take those + * keys into account while deciding what to do with the remaining tuples, ie + * it should try to "build out" from those unions so as to minimally expand + * them. If it does so, it should union the given tuples' keys into the + * existing spl_ldatum/spl_rdatum values rather than just setting those values + * from scratch, and then set spl_ldatum_exists/spl_rdatum_exists to false to + * show it has done this. + * + * If the PickSplit method fails to clear spl_ldatum_exists/spl_rdatum_exists, + * the core GiST code will make its own decision about how to merge the + * secondary-split results with the previously-chosen tuples, and will then + * recompute the union keys from scratch. This is a workable though often not + * optimal approach. */ typedef struct GIST_SPLITVEC { diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h index d0d5262fe0c..d9b1fa2fec5 100644 --- a/src/include/access/gist_private.h +++ b/src/include/access/gist_private.h @@ -254,20 +254,21 @@ typedef struct GISTInsertStack struct GISTInsertStack *parent; } GISTInsertStack; +/* Working state and results for multi-column split logic in gistsplit.c */ typedef struct GistSplitVector { - GIST_SPLITVEC splitVector; /* to/from PickSplit method */ + GIST_SPLITVEC splitVector; /* passed to/from user PickSplit method */ Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in - * spl_left */ + * splitVector.spl_left */ bool spl_lisnull[INDEX_MAX_KEYS]; Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in - * spl_right */ + * splitVector.spl_right */ bool spl_risnull[INDEX_MAX_KEYS]; - bool *spl_equiv; /* equivalent tuples which can be freely - * distributed between left and right pages */ + bool *spl_dontcare; /* flags tuples which could go to either side + * of the split for zero penalty */ } GistSplitVector; typedef struct @@ -526,7 +527,7 @@ extern Datum gistvacuumcleanup(PG_FUNCTION_ARGS); /* gistsplit.c */ extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate, - GistSplitVector *v, GistEntryVector *entryvec, + GistSplitVector *v, int attno); /* gistbuild.c */ |