1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +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

@ -1145,8 +1145,8 @@ CREATE UNIQUE INDEX tab_x_y ON tab(x) INCLUDE (y);
likely to not need to access the heap. If the heap tuple must be visited
anyway, it costs nothing more to get the column's value from there.
Other restrictions are that expressions are not currently supported as
included columns, and that only B-tree indexes currently support included
columns.
included columns, and that only B-tree and GiST indexes currently support
included columns.
</para>
<para>
@ -1165,7 +1165,7 @@ CREATE INDEX tab_x_y ON tab(x, y);
enforce uniqueness on the key column(s). Also, explicitly marking
non-searchable columns as <literal>INCLUDE</literal> columns makes the
index slightly smaller, because such columns need not be stored in upper
B-tree levels.
tree levels.
</para>
<para>

View File

@ -181,10 +181,10 @@ CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] <replaceable class=
</para>
<para>
Currently, only the B-tree index access method supports this feature.
In B-tree indexes, the values of columns listed in the
<literal>INCLUDE</literal> clause are included in leaf tuples which
correspond to heap tuples, but are not included in upper-level
Currently, the B-tree and the GiST index access methods supports this
feature. In B-tree and the GiST indexes, the values of columns listed
in the <literal>INCLUDE</literal> clause are included in leaf tuples
which correspond to heap tuples, but are not included in upper-level
index entries used for tree navigation.
</para>
</listitem>

View File

@ -3674,6 +3674,12 @@ SELECT plainto_tsquery('supernovae stars');
retrieved to see if the match is correct.
</para>
<para>
A GiST index can be covering, i.e. use the <literal>INCLUDE</literal>
clause. Included columns can have data types without any GiST operator
class. Included attributes will be stored uncompressed.
</para>
<para>
Lossiness causes performance degradation due to unnecessary fetches of table
records that turn out to be false matches. Since random access to table