i have a problem with this query:
SELECT city,6371 * ACos( Cos(RADIANS(Lat)) * Cos(RADIANS(51.166698)) * Cos(RADIANS(-1.7833) - RADIANS(Lng)) + Sin(RADIANS(Lat)) * Sin(RADIANS(51.166698)) ) AS Distance
FROM GeoPC
GROUP BY city ORDER BY Distance LIMIT 20
The query needs about 30 seconds. There are about 1.7 million rows in the database and the group by and the order by is too heavy for the database. Any idea how i can fix it?