Proximity search: finding what is nearby
"Show me what is near me" is a range query in two dimensions, which an ordinary index handles badly, so the real design choice is how to turn location into something an index can range-scan (a geohash, a quadtree, an S2 or H3 cell) and whether the things you are searching for sit still or move every few seconds.
What you'll be able to do
- Explain why separate or composite B-tree indexes on latitude and longitude scan far more rows than a nearby query needs
- Encode a point as a geohash, choose a precision for a given radius, and handle the cell-boundary case by querying neighbours
- Compare geohash, quadtrees, S2 and H3, and name the off-the-shelf option (PostGIS, Redis GEO, Elasticsearch) that fits a prompt
- Size and design the write path for moving objects such as drivers, separately from static places
Before this: back-of-the-envelope, picking-a-datastore
Log in to read the rest of this lesson
"Show me what is near me" is a range query in two dimensions, which an ordinary index handles badly, so the real design choice is how to turn location into something an index can range-scan (a geohash, a quadtree, an S2 or H3 cell) and whether the things you are searching for sit still or move every few seconds. This walkthrough runs about 22 minutes, with runnable code you can edit and re-run as you read. A new account gets 7 days of Pro free, no card required.
Log in to continueThe first module of every track is free to read on the web: see what's open in System design.