I'm curious what the most efficient way to index this would be in the context of, for instance, a map-based store locator.
- The user pans/zooms the map to the region they would like to view.
- The application determines the bounds of the viewport, aka max/min for lat/lng.
A query is issued in the basic form:
SELECT *
FROM locations
WHERE lat BETWEEN $min_lat AND $max_lat
AND lng BETWEEN $min_lng AND $max_lng
Is it best to use a single composite INDEX(lat, lng)
, or two separate indexes like INDEX(lat), INDEX(lng)
?