Crear un índice compuesto en (state, city)
y reescriba su consulta así:
SELECT CONCAT_WS(', ', city, state) AS location, AVG(latitude), AVG(longitude)
FROM places
WHERE state='NY'
AND city='New York'
GROUP BY
state, city
Tenga en cuenta que para esta misma consulta puede omitir GROUP BY
cláusula:
SELECT 'New York, NY' AS location, AVG(latitude), AVG(longitude)
FROM places
WHERE state='NY'
AND city='New York'
Sin embargo, esta consulta aún la necesitará:
SELECT CONCAT_WS(', ', city, state) AS location, AVG(latitude), AVG(longitude)
FROM places
WHERE state='NY'
GROUP BY
state, city