How to optimize SQL query with calculating distance by longitude and latitude?
问题 I have a table with structure like that: table name: shop id_shop int(10) name varchar(200) latitude double longitude double And I'd like to calculate distance between given coordinates and coordinates saved in database. My current query: SELECT * FROM `shop` AS `s` WHERE ( ( 6371 * ACOS( SIN( RADIANS( latitude ) ) * SIN( RADIANS( 53.5353010379 ) ) + COS( RADIANS( latitude ) ) * COS( RADIANS( 53.5353010379 ) ) * COS( RADIANS( 14.7984442616 ) - RADIANS( longitude ) ) ) ) <= 25 ) plus some JOIN