Last Updated: May 26, 2026
Many location systems need to find nearby places without scanning every latitude and longitude row.
Geohash converts a two-dimensional location into a hierarchical string. Nearby points often share a prefix, so ordinary ordered indexes can fetch a small set of candidate locations.
Geohash is a coarse filter, not an exact distance engine. Production queries still need neighboring cells, exact distance checks, and careful precision choices.
Geohash is a hierarchical spatial encoding for latitude and longitude. It divides the Earth into rectangular cells and assigns each cell a short Base32 string.
Longer strings represent smaller cells:
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, prefix-match it, and index it with a B-tree.
Points with the same geohash prefix are in the same rectangular region. Points near each other often share a prefix, but not always. Cell boundaries are the main edge case you must design for.
Here is the core idea:
This hierarchy is why prefix queries work. Searching for 9q8yy% means "find points stored in this cell and its descendants."