1
set @dist = 100;
set @rlng1 = [email protected]/abs(cos(radians(31.34747060000000))*69);
set @rlng2 = [email protected]/abs(cos(radians(31.34747060000000))*69);
set @rlat1 = 31.34747060000000-(@dist/69);
set @rlat2 = 31.34747060000000+(@dist/69);
SELECT name,storeId, ST_DISTANCE(POINT(48.67607474000000,31.34747060000000),
POINT(lng, lat)) AS distance
FROM store
WHERE ST_WITHIN(POINT(48.67607474000000,31.34747060000000),
ENVELOPE(LINESTRING(point(@rlng1, @rlat1),
point(@rlng2, @rlat2))))
ORDER by distance
LIMIT 10 OFFSET 0;
我有一個查詢來獲取用戶附近的商店...MySQL的搜索按距離順序是慢
這是我的查詢..當我運行查詢不正常(按距離順序)0.0161我的查詢運行秒但是,當我使用(按距離排序)我的查詢運行在2.8791秒。
我應該怎麼做才能在我的查詢上獲得最佳運行時間按距離排序?