Practice this topic in a realistic system design interview
Many location systems need to answer a simple question quickly:
What places are near this point?
The slow way is to scan every latitude and longitude in the database and compute distance one by one. That does not work when the database has millions of restaurants, drivers, stores, or devices.
Geohash helps by turning a location into a short string. Nearby places often share the same starting characters, so a normal ordered index can fetch a smaller set of candidates first.
Geohash is not an exact distance calculator. It is a first-pass filter. Real systems still need to check neighboring cells, compute the actual distance, and choose the right precision for the product.
This chapter explains how Geohash encoding works, how precision changes the search area, how nearby search works, and where Geohash can surprise you.
Geohash is a way to turn latitude and longitude into a short string.
It works by dividing the Earth into rectangles. Each rectangle gets a string. Longer strings point to smaller rectangles.
For example:
9q8yy covers a broad area around San Francisco.9q8yyk covers a smaller cell inside that area.9q8yyk8 covers a still smaller cell.Invented by Gustavo Niemeyer in 2008, Geohash became popular because it fits cleanly into existing storage systems. A geohash is just a string, so you can store it in a normal column, sort it, search by prefix, and index it with a B-tree.
Points with the same geohash prefix are in the same rectangular region. Nearby points often share a prefix, but not always. Cell boundaries are the main edge case to remember.
Here is the core idea:
This nesting is why prefix queries work. Searching for 9q8yy% means "find points stored in this cell and smaller cells inside it."