Why do separate B-tree indexes on latitude and longitude fail for proximity search?

Test your Systems Design Concepts knowledge with our comprehensive quiz. Utilize flashcards and multiple choice questions to enhance your study session. Prepare thoroughly with detailed explanations for each answer and ace your examination!

Multiple Choice

Why do separate B-tree indexes on latitude and longitude fail for proximity search?

Explanation:
Proximity search in two dimensions needs to consider latitude and longitude together. A B-tree on latitude orders points by one dimension, and a separate B-tree on longitude orders points by the other. To find nearby points, you’d have to pull points from a latitude window and a longitude window and then intersect those results. That creates a large set of candidate points arranged as broad rectangles in the plane, many of which are far from the query location. You then must compute the actual distance for each candidate to filter out the far ones, which is very inefficient. In contrast, a spatial index (like an R-tree, kd-tree, or a grid/geohash-based index) organizes data with the two dimensions in mind, so proximity queries can directly prune candidates that are outside the radius without enumerating a huge cross-section. That’s why separate 1D indexes fail for proximity search: they don’t capture the joint spatial relationship between latitude and longitude, forcing heavy post-filtering.

Proximity search in two dimensions needs to consider latitude and longitude together. A B-tree on latitude orders points by one dimension, and a separate B-tree on longitude orders points by the other. To find nearby points, you’d have to pull points from a latitude window and a longitude window and then intersect those results. That creates a large set of candidate points arranged as broad rectangles in the plane, many of which are far from the query location. You then must compute the actual distance for each candidate to filter out the far ones, which is very inefficient.

In contrast, a spatial index (like an R-tree, kd-tree, or a grid/geohash-based index) organizes data with the two dimensions in mind, so proximity queries can directly prune candidates that are outside the radius without enumerating a huge cross-section. That’s why separate 1D indexes fail for proximity search: they don’t capture the joint spatial relationship between latitude and longitude, forcing heavy post-filtering.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy