Need help optimizing a lat/Lon geo search for mysql

后端 未结 5 1578
走了就别回头了
走了就别回头了 2021-01-03 07:09

I have a mysql (5.0.22) myisam table with roughly 300k records in it and I want to do a lat/lon distance search within a five mile radius.

I have an index that cov

5条回答
  •  庸人自扰
    2021-01-03 08:04

    You are probably using a 'covering index' in your lat/lon only query. A covering index occurs when the index used by the query contains the data that you are selecting for. MySQL only needs to visit the index and never the data rows. See this for more info. That would explain why the lat/lon query is so fast.

    I suspect that the calculations and the sheer number of rows returned, slows down the longer query. (plus any temp table that has to be created for the having clause).

提交回复
热议问题