Geohash
Updated June 3, 2026Have you ever wondered how apps like Uber or Tinder know exactly who is around you in milliseconds? If they had to calculate the exact distance between you and every other user on earth using complex math, your phone would probably melt.
Instead, they use a clever trick called a Geohash.
The World is a Waffle
Think of the Earth as a giant waffle. A Geohash takes the entire globe and divides it into a grid. Each square in that grid gets a unique letter or number.
But it doesn't stop there. If you zoom in on one of those squares, you'll see it's actually made of smaller squares, and each of those smaller squares has its own unique letter or number added to the end of the first one.
This process keeps going. The more letters you add to your Geohash, the smaller the square gets, and the more precise your location becomes.
For example:
9might cover half of North America.9qnarrows it down to the West Coast.9q8gets you into California.9q8yygets you into San Francisco.9q8yyk8pinpoints a specific coffee shop in SF.
What does a longer Geohash string represent?
Why is this so powerful?
In a database, searching for points within a radius using raw latitude and longitude is computationally expensive. You have to use the Haversine formula on every row.
With Geohashes, finding nearby points becomes a simple prefix string match.
If your Geohash is 9q8yy, and you want to find drivers near you, you just ask the database: "Give me all drivers whose location starts with 9q8yy."
Databases (like Redis, MongoDB, or PostgreSQL) are incredibly fast at matching string prefixes using indexes. This turns a complex math problem into a lightning-fast text search.
Why are Geohashes faster for proximity searches than raw latitude/longitude?
The Edge Case (Literally)
There's one catch: two places can be right next to each other but sit on opposite sides of a grid boundary, meaning their Geohashes will look completely different.
Imagine you are standing on the border of a square. Your Geohash might be 9q8yy, but a car 10 feet away across the border might be in 9q8yz. A simple prefix search for 9q8yy would miss that car entirely!
To solve this, real-world systems don't just query your exact Geohash square. They query your square plus the 8 surrounding squares. This ensures you catch everything nearby, even across boundaries.
Two locations right next to each other can have completely different Geohashes.
How do real-world systems handle the Geohash boundary edge case?
Real-World Examples
- Uber and Lyft: Use Geohashes to quickly group drivers and riders in the same area.
- Tinder: Uses similar grid-based systems to find potential matches within your specified radius.
- Yelp: Uses them to find restaurants near your current location without scanning the entire country.
A Geohash prefix search on `9q8yy` will always find all drivers within a fixed radius of that cell.
Summary
Geohashes turn 2D coordinates (latitude and longitude) into 1D strings. They divide the world into a hierarchical grid, where longer strings mean more precise locations. By converting proximity into string prefix matching, they allow databases to find nearby points with incredible speed, making location-based apps possible at a massive scale.
Saved on this device only
Sign in to sync progress across devices