DELAPARRA
Index
Color
NL
Category: SQL

GiST index

Explained by Updated

What is GiST index?

GiST index: Generalised Search Tree (Postgres) — for geometric, range, and nearest-neighbour queries (PostGIS, ranges). A GiST index, short for Generalised Search Tree, is a flexible PostgreSQL index type for data that does not sort neatly in one dimension. Geographic shapes, date ranges and nearest-neighbour searches are its main uses. With PostGIS, a GiST index makes queries like "all shops within five kilometres" fast. For range types, it speeds up checks for overlapping periods, which is exactly what a booking system needs to prevent double bookings.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about GiST index

What should you keep in mind with GiST index?

PostgreSQL can even enforce such rules with an exclusion constraint backed by GiST, so two bookings for the same room can never overlap, whatever the application code does. For ordinary columns like IDs, names and dates, the default B-tree index remains the right choice. GiST is for the specialised cases where B-tree cannot help.

What does an example of GiST index look like?

CREATE INDEX idx_shapes_geom ON shapes USING gist (geom);

At a glance

CategorySQL
Explained by
Updated

More SQL terms

All terms starting with G

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.