Geohash prefixes and cell edges 00:00:01 The two riders cross a prefix line Two riders stop twelve metres apart. A grid boundary runs between their bikes. A dispatch service looking for a rider within fifty metres searches one exact geohash prefix and reports nobody. A geohash encodes successive longitude and latitude splits into characters. All full coordinates that begin with the same chosen prefix fall into its rectangular cell. Our two riders occupy distinct cells at this precision. Sharing a long prefix can indicate a common small region. Being nearby does not oblige two coordinates to share that prefix. Picture the two handlebars on opposite sides of a painted line. Moving either handlebar a centimetre across the line can change its code immediately while barely moving its actual location. 00:00:52 Shorten and lengthen the prefix Shorten the prefix of one rider by one character. Its smaller rectangle is now part of a larger parent rectangle, so many more coordinates can share the shortened code. Lengthen it again. The cell becomes more selective. Whether two riders share the new code depends on the locations of both coordinates and the subdivision lines. A rider next to a cell corner can have nearby neighbors in several adjacent buckets. Increasing precision alone does not repair the omission in a single-bucket query. At each added base-thirty-two character, five more interleaved coordinate bits narrow the bounds. The rectangle has an extent, not a universally fixed width in metres. Latitude affects its east-west width. 00:01:40 Search the neighboring buckets For the fifty-metre dispatch query, enumerate or cover all cells that could intersect the circle. On some combinations of radius and cell size the immediate neighbors are enough. Now keep the radius fixed and make cells much smaller. The same circle can span several rows of cells. Checking only the eight immediate neighbors would stop too early. Choose the coverage from the actual query extent. A longer radius or a different latitude can change the required set without any change in how the geohash encoder works. A simple safe plan is to cover a bounding region around the circle, including any longitude wrap, then refine. The number of bucket reads follows the actual cover for the selected precision. 00:02:26 Refine on coordinates We collect all rider IDs from the covering set and remove duplicates to avoid sending the same rider twice. Now we compute the actual Earth distance using the haversine formula, since rectangular bounds can mislead. One rider in the corner of a cell was 53 meters away, so even though the cell covers the area, it’s outside the 50-meter limit. Keep the rider coordinates beside the index entry, or fetch them by identifier. The rectangle containing the rider tells you where to look; the coordinate gives evidence for the final distance comparison. 00:03:01 Choose precision for this workload In a busy area, short prefixes may return a crowd of false candidates. In a sparse area, very fine cells may create many empty lookups. Both can still yield the same correct answer. Record buckets read, candidate count, actual matches, and duration while changing precision. Compare each result set with a reference full-distance scan so an apparently fast omission cannot win. Select the precision for the observed traffic and geographic coverage. For the two bikes on our painted line, the right test is simple. Both sides must be searched before distance decides. Replay a route that crosses a prefix boundary and inspect the index update lag. A perfectly designed static query can still miss a recently moved rider when its entry or coordinate version is stale.