HomeData SciencePostGIS Spatial Index Explorer

🗺️ How PostGIS Turns PostgreSQL into a Spatial Query Engine

Draw a bounding-box query over a 3D map of scattered points and watch a spatial R-tree/GiST index highlight only the grid cells it needs to search, instead of scanning every point in the table.

Data Science3DModerate60 FPS
postgis-spatial-indexing-postgres-lab ↗ Open standalone

A 3D map scattered with data points sits under a spatial R-tree/GiST index grid. Draw a bounding-box query and watch the index highlight only the cells — and the rows inside them — it actually needs to search.

🔬 What It Demonstrates

PostGIS's GiST index groups geometries into bounding boxes so a query can discard whole branches of the tree at once. Amber points are candidates inside searched cells; green points are exact matches inside the query box; grey points were never touched.

🎮 How to Use

Move the query box with the X/Z sliders and resize it, then change the index granularity to see the searched-cell count shrink or grow. Hit "Compare full table scan" to see what scanning every row without an index looks like.

💡 Did You Know?

PostGIS is built on PostgreSQL's generic GiST framework — the same indexing machinery that also powers full-text search — with bounding-box splitting rules registered specifically for geometry columns.

⚙ Under the hood

Interactive 3D map-and-index scene where running spatial queries shows how PostGIS's R-tree indexing turns PostgreSQL into a fast geospatial query engine.

postgisspatial-indexingpostgresqlgeospatial-databasesr-treequery-optimizationdata-science

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)