Grokking Redis
Vote

0% completed

​

5.6 Geospatial Queries

Which drivers are within 2 km of this rider? Computing the distance from the rider to every driver answers the question, but that is O(N) work per request, which is far too slow with millions of drivers. Every geo system uses the same idea instead: turn a two-dimensional location into one number that an ordinary ordered index can scan by range. Redis encodes each coordinate pair as a single integer and stores it as the score in a sorted set.

How Geohash Turns Two Dimensions into One

A geohash is built by repeatedly halving the map. Start with the whole world as one box

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content