RefLib

Reference library for AI

Back

postgresql_16:3.8.2.3 GiST

PostgreSQL 16 > The SQL Language > Indexes > Index Types > GiST

GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented. Accordingly, the particular operators with which a GiST index can be used vary depending on the indexing strategy (the *operator class*). As an example, the standard distribution of PostgreSQL includes GiST operator classes for several two-dimensional geometric data types, which support indexed queries using these operators: <<   &<   &>   >>   <<|   &<|   |&>   |>>   @>   <@   ~=   && (See (see postgresql_16:3.6.11) for the meaning of these operators.) The GiST operator classes included in the standard distribution are documented in (see gist-builtin-opclasses-table). Many other GiST operator classes are available in the contrib collection or as separate projects. For more information see (see postgresql_16:8.17).

GiST indexes are also capable of optimizing “nearest-neighbor” searches, such as SELECT * FROM places ORDER BY location <-> point '(101,456)' LIMIT 10; which finds the ten places closest to a given target point. The ability to do this is again dependent on the particular operator class being used. In (see gist-builtin-opclasses-table), operators that can be used in this way are listed in the column “Ordering Operators”.

Back