liveBook · Manning

SP-GiST index

As explained in Just Use Postgres!

An SP-GiST index is a space-partitioned generalized search tree index for data structures that support recursive partitioning.

An SP-GiST (space-partitioned generalized search tree) index recursively partitions spatial data into non-overlapping regions. It is especially useful for evenly distributed point data. section 10.6

For geospatial workloads, SP-GiST works by:

  • Dividing space around a selected centroid into four non-overlapping quadrants. section 10.6
  • Recursively splitting top-level quadrants into smaller regions with their own centroids. section 10.6
  • Traversing from broad regions to smaller quadrants containing references to indexed geometries. section 10.6

Uniformly distributed points

A map containing many points spread evenly across space is a strong candidate: points do not overlap by nature, so the index can narrow searches through progressively smaller quadrants. Choose GiST instead when broader spatial operator and function support matters. section 10.6 section 10.7

How Just Use Postgres! covers it

How deep it goes
Explains recursive quadrant partitioning and search traversal, but stops short of implementation details and operator definitions.
Examples
Uses uniformly distributed point data and recursively subdivided spatial quadrants as its concrete examples.
What it assumes
Assumes familiarity with PostgreSQL indexes and geospatial data while distinguishing index purpose from access method.
What you can do after
Evaluate/understand when SP-GiST suits geospatial data and when GiST offers broader operator support.
How it connects
Connects SP-GiST with PostGIS, geospatial data, GiST, BRIN, and PostgreSQL access methods.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Just Use Postgres!. The section links point to the parts of the book it draws on.