Hello I have table with 500k records and folowing columns:
id, id_route, id_point, lat, lng, distance, status
I want to select id_routes which are inside radius from my defined point.
Thats no problem
SELECT id_route
FROM route_path
WHERE (((lat < 48.7210 + 2.0869) AND
(lat > 48.7210 - 2.0869)) AND
((lng < 21.2578 + 2.0869) AND
(lng > 21.2578 - 2.0869)))
GROUP BY id_route
But according PHPmyadmin it takes 0.2s. This is pretty to much since I am going to build huge query and this is just beginning.
I have also index on id_route.
Primary key is id, schema is MyISAM
EXPLAIN of SELECT:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE route_path ALL NULL NULL NULL NULL 506902 Using where; Using temporary; Using filesort
How can I reduce time, I think 500K is not su much records to make it so long? Thanks