
Aaron Francis looks into querying MySQL with a ST_Distance_Sphere clause — a function to calculate the linear distance in meters between two lon/lat points — in an efficient way. There’s a few things he does there:
- No unnecessary calculations in
WHEREclauses - Pre-limiting the set by applying a bounding box
- Leveraging Generated Columns
- Using a Spatial Index
Efficient Distance Querying in MySQL →
~
Via Freek