Can you explain the reason behind why plain hashing on the geohash string wont work? As you wrote in this point?
> We still might be doing full table scans to find the relevant places. There has been no indexing done till now. Even if you do indexing on the full 10-length geohash stored in the SQL table, there might be some geohash indexes that have only 1 place inside the index. Hmm, not a very good use case for building indexes.
Indexes are built on a column so that search queries can filter the required dataset in less time. If we pick any 10-length geohash, then it will represent an area of 1 meter square. The number of places in this area or index would be very less. Thus, we might have to scan multiple indexes to get the desired data which defeats the purpose of having an index.
Thus, it's not a good idea to build index on full 10-length geohash.
What would be more amazing is: if we have index built on first 5-length geohash and then a lot of places would be included in this index. Thus, the data scanning will be much faster and search queries will run in less time.
Thanks for the amazing blog. Just had one confusion though:
You mentioned: "The string comparisons are faster than float comparisons."
I think this is not true in general. The reason I though geo-hash outperforms traditional lat-long + distance based approach is there is no way to index {lat, long} in such a way that they can be effectively utilised (either one of them will always be unsorted in the index.
But when we convert {lat, long} into a geo-hash we are converting a 2D data -> 1D data which can be indexed in B/B+ trees.
I think, if we just use a geo-hash based query without indexing it will actually perform worse than the normal lat-long based methods.
Please let me know if I am getting anything wrong...
Wow. This is the most helpful post I ever came across. Thanks a lot.
Can you explain the reason behind why plain hashing on the geohash string wont work? As you wrote in this point?
> We still might be doing full table scans to find the relevant places. There has been no indexing done till now. Even if you do indexing on the full 10-length geohash stored in the SQL table, there might be some geohash indexes that have only 1 place inside the index. Hmm, not a very good use case for building indexes.
Hey Raghwendra,
Indexes are built on a column so that search queries can filter the required dataset in less time. If we pick any 10-length geohash, then it will represent an area of 1 meter square. The number of places in this area or index would be very less. Thus, we might have to scan multiple indexes to get the desired data which defeats the purpose of having an index.
Thus, it's not a good idea to build index on full 10-length geohash.
What would be more amazing is: if we have index built on first 5-length geohash and then a lot of places would be included in this index. Thus, the data scanning will be much faster and search queries will run in less time.
Very good guide on this
Thanks for the amazing blog. Just had one confusion though:
You mentioned: "The string comparisons are faster than float comparisons."
I think this is not true in general. The reason I though geo-hash outperforms traditional lat-long + distance based approach is there is no way to index {lat, long} in such a way that they can be effectively utilised (either one of them will always be unsorted in the index.
But when we convert {lat, long} into a geo-hash we are converting a 2D data -> 1D data which can be indexed in B/B+ trees.
I think, if we just use a geo-hash based query without indexing it will actually perform worse than the normal lat-long based methods.
Please let me know if I am getting anything wrong...
Thanks again for the great blog!