Spatial Joins in DuckDB

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

DuckDB's spatial joins now run 60x faster, making city-scale geospatial analytics practical on a laptop without a spatial database.

Read this as

DuckDB, a free database tool, got much faster at answering 'which area does each point fall in?' questions. A test counting 58 million bike trips against 310 neighborhood maps took 30 minutes with the old approach, 107 seconds with a first improvement, and just 30 seconds after a second improvement shipped in version 1.3.0. Anyone doing map-based analysis on ordinary computers benefits.

Teams running geospatial queries in DuckDB can now skip expensive dedicated spatial databases for many workloads. A real query over 58 million NYC bike trips dropped from 30 minutes to 30 seconds on a MacBook M3 Pro purely through version upgrades, 1.2.0's bounding-box pre-filtering plus 1.3.0's automatic R-Tree indexing. No new hardware or migration cost is mentioned; the gains come free with upgrading.

Max Gabrielsson's post benchmarks DuckDB's ST_Intercepts spatial join over 58,033,724 Citi Bike rows against 310 neighborhood polygons. Naive nested-loop joins execute ~18 billion intersections (~30 min). DuckDB 1.2.0 caches minimum bounding rectangles in GEOMETRY and does a piecewise merge join on bounding boxes before exact intersection (107s). DuckDB 1.3.0's SPATIAL_JOIN operator auto-builds an in-memory R-Tree over the larger table's bounding boxes, cutting runtime to 30 seconds.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

DuckDB ST_Intersects NYC Citi Bike Trips NYC Neighborhood Tabulation Areas SPATIAL_JOIN MacBook M3 Pro R-Tree

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading