mysql添加距离函数
问题:随着数据的增多,计算距离的函数会遍历全部数据,导致sql执行变慢。不适合数据量很大的表。
SELECT
*
FROM
(
SELECT
get_distance( ‘118.79926367881872’, ‘31.98749838084618’, s. longitude, s. latitude) DISTANCE, s. id, s. station_name, s. station_type, s. province_code, s. city_code, s. area_code, s. longitude, s. latitude, s. code_address, s. address, s. create_time, b. license_key, b. service_Status
FROM
data_station_info s
LEFT JOIN data_station_base_info b ON b. id = s. id
WHERE
s. is_delete = 0
) t
ORDER BY
t. DISTANCE asc
LIMIT
10