Crea un indice composito su (state, city)
e riscrivi la tua domanda in questo modo:
SELECT CONCAT_WS(', ', city, state) AS location, AVG(latitude), AVG(longitude)
FROM places
WHERE state='NY'
AND city='New York'
GROUP BY
state, city
Nota che per questa stessa query puoi omettere GROUP BY
clausola:
SELECT 'New York, NY' AS location, AVG(latitude), AVG(longitude)
FROM places
WHERE state='NY'
AND city='New York'
Tuttavia, questa query ne avrà ancora bisogno:
SELECT CONCAT_WS(', ', city, state) AS location, AVG(latitude), AVG(longitude)
FROM places
WHERE state='NY'
GROUP BY
state, city