educative.io

Why to have index on GridId in Hash Table with LocationId

Whats the point of keeping GRID in hash Table with all the location . I thought we are going to keep GRIDID at each row of location entry: LocationId, Name, Long, Lat, Description,GridID, Category.
Based on which

Select * from Places where Latitude between X-D and X+D and Longitude between Y-D and Y+D and GridID in (GridID, GridID1, GridID2, …, GridID8)

was given. If we keep the location with GridId then we can directly get all the Location without the doing query as mentioned above and without keeping GridId information in the Location Table.

Please explain :slight_smile: