algomiBlogs
← All posts

Location-Based Services: Geohash, Quadtrees, Nearby Search, and Ride Matching

Algomi Research · Created 2026-09-29 · Updated 2026-10-15 · System Design

Interview Roadmap Deep Dives · Part 11 of 28
Search, Autocomplete, Web Crawling, Time-Series, and Ad-Click AggregationCollaborative Editing: Operational Transformation, CRDTs, and Presence
Page 1 of 1

Farah wants the nearest chai stall

Farah builds ChaiMap, an app that answers one question: where is the nearest good chai stall? A year later she adds ChaiRide, which books an auto-rickshaw to take you there. (Farah, both apps and every number here are made up for teaching.)

Think about how you find the nearest stall in a big city. You don't measure the distance to every stall in the country. You narrow down to your neighbourhood, then compare the few stalls in it. Location systems do the same thing: chop the map into cells, index things by cell, and search your cell and its neighbours.

Farah's journey raises every question this topic asks:

Problem Idea it forces
"The nearby query scans half of India" Why plain indexes fail
"How do I cut up the map?" Geohash
"The stall 50 m away didn't show up" Searching neighbouring cells
"Mumbai has 1,000 stalls per square km, my village has 3" Quadtrees, S2, H3
"Build it for real" A proximity service for static places
"Autos move every 4 seconds" A write-heavy live-location pipeline
"Two riders got the same auto" Locking the matched driver
"The nearest auto was across the river" Ranking by road ETA

This guide follows Search. Its ride-matching part connects to BookMyShow for the "reserve a scarce thing" pattern.

1. "The nearby query scans half of India": why plain indexes fail

Farah's first query:

SELECT * FROM places WHERE lat BETWEEN ... AND lon BETWEEN ...

The database uses one index, on latitude or longitude. Latitude alone matches a thick horizontal band right across the planet, through Mumbai, Kolkata and a dozen countries. Two separate one-dimensional indexes can't serve a two-dimensional range well. Farah needs an index that keeps points that are near each other on the map near each other in the index.

2. "How do I cut up the map?": geohash

You've reached the free preview of this post.

Subscribe to the Blogs plan (₹99/mo) — or use any Algomi Suite, Career, Investor, or Trader plan — to keep reading.

See plans

Sources

Interview Roadmap Deep Dives · Part 11 of 28
Search, Autocomplete, Web Crawling, Time-Series, and Ad-Click AggregationCollaborative Editing: Operational Transformation, CRDTs, and Presence