GIST (Generalized Search Tree)
PostgreSQL Full Text Search Gist (Generalized Search Tree) Index
https://www.postgresql.org/docs/current/gist.html
CREATE INDEX name ON table USING GIST (column [ { DEFAULT | tsvector_ops } (siglen = number) ] );
Feature
- index is
lossy
, meaning that the index might produce false matches
- because each document is represented in the index by a
fixed-length signature
Scenario
- point in a geometric space
- polygon
Data type
- spatial data types
- geometry
- geography
Built-in Operator Classes
https://www.postgresql.org/docs/current/gist-builtin-opclasses.html
box_ops
Indexable Operators |
Ordering Operators |
<< (box, box) |
<-> (box, point) |
&< (box, box) |
|
&& (box, box) |
|
&> (box, box) |
|
>> (box, box) |
|
~= (box, box) |
|
@> (box, box) |
|
<@ (box, box) |
|
&<| (box, box) |
|
<<| (box, box) |
|
|>> (box, box) |
|
|&> (box, box) |
|
~ (box, box) |
|
@ (box, box) |
|
circle_ops
Indexable Operators |
Ordering Operators |
<< (circle, circle) |
<-> (circle, point) |
&< (circle, circle) |
|
&> (circle, circle) |
|
>> (circle, circle) |
|
<@ (circle, circle) |
|
@> (circle, circle) |
|
~= (circle, circle) |
|
&& (circle, circle) |
|
|>> (circle, circle) |
|
<<| (circle, circle) |
|
&<| (circle, circle) |
|
|&> (circle, circle) |
|
@ (circle, circle) |
|
~ (circle, circle) |
|
inet_ops
Indexable Operators |
Ordering Operators |
<< (inet, inet) |
|
<<= (inet, inet) |
|
>> (inet, inet) |
|
>>= (inet, inet) |
|
= (inet, inet) |
|
<> (inet, inet) |
|
< (inet, inet) |
|
<= (inet, inet) |
|
> (inet, inet) |
|
>= (inet, inet) |
|
&& (inet, inet) |
|
For historical reasons, the inet_ops operator class is NOT the default class
for types inet
and cidr
. To use it, mention the class name in CREATE INDEX, for example
CREATE INDEX ON my_table USING GIST (my_inet_column inet_ops);
multirange_ops
Indexable Operators |
Ordering Operators |
= (anymultirange, anymultirange) |
|
&& (anymultirange, anymultirange) |
|
&& (anymultirange, anyrange) |
|
@> (anymultirange, anyelement) |
|
@> (anymultirange, anymultirange) |
|
@> (anymultirange, anyrange) |
|
<@ (anymultirange, anymultirange) |
|
<@ (anymultirange, anyrange) |
|
<< (anymultirange, anymultirange) |
|
<< (anymultirange, anyrange) |
|
>> (anymultirange, anymultirange) |
|
>> (anymultirange, anyrange) |
|
&< (anymultirange, anymultirange) |
|
&< (anymultirange, anyrange) |
|
&> (anymultirange, anymultirange) |
|
&> (anymultirange, anyrange) |
|
-|- (anymultirange, anymultirange) |
|
-|- (anymultirange, anyrange) |
|
point_ops
Indexable Operators |
Ordering Operators |
|>> (point, point) |
<-> (point, point) |
<< (point, point) |
|
>> (point, point) |
|
<<| (point, point) |
|
~= (point, point) |
|
<@ (point, box) |
|
<@ (point, polygon) |
|
<@ (point, circle) |
|
poly_ops
Indexable Operators |
Ordering Operators |
<< (polygon, polygon) |
<-> (polygon, point) |
&< (polygon, polygon) |
|
&> (polygon, polygon) |
|
>> (polygon, polygon) |
|
<@ (polygon, polygon) |
|
@> (polygon, polygon) |
|
~= (polygon, polygon) |
|
&& (polygon, polygon) |
|
<<| (polygon, polygon) |
|
&<| (polygon, polygon) |
|
|&> (polygon, polygon) |
|
|>> (polygon, polygon) |
|
@ (polygon, polygon) |
|
~ (polygon, polygon) |
|
range_ops
Indexable Operators |
Ordering Operators |
= (anyrange, anyrange) |
|
&& (anyrange, anyrange) |
|
&& (anyrange, anymultirange) |
|
@> (anyrange, anyelement) |
|
@> (anyrange, anyrange) |
|
@> (anyrange, anymultirange) |
|
<@ (anyrange, anyrange) |
|
<@ (anyrange, anymultirange) |
|
<< (anyrange, anyrange) |
|
<< (anyrange, anymultirange) |
|
>> (anyrange, anyrange) |
|
>> (anyrange, anymultirange) |
|
&< (anyrange, anyrange) |
|
&< (anyrange, anymultirange) |
|
&> (anyrange, anyrange) |
|
&> (anyrange, anymultirange) |
|
-|- (anyrange, anyrange) |
|
-|- (anyrange, anymultirange) |
|
tsquery_ops
Indexable Operators |
Ordering Operators |
<@ (tsquery, tsquery) |
|
@> (tsquery, tsquery) |
|
tsvector_ops
Indexable Operators |
Ordering Operators |
@@ (tsvector, tsquery) |
|
Reference