optimization - Optimizing Sqlite query for INDEX -
i have table of 320000 rows contains lat/lon coordinate points. when user selects location program gets coordinates selected location , executes query brings points table near. done calculating distance between selected point , each coordinate point table row. query use:
select street locations ( ( (lat - (-34.594804)) *(lat - (-34.594804)) ) + ((lon - (-58.377676 ))*(lon - (-58.377676 ))) <= ((0.00124)*(0.00124))) group street;
as can see clause simple pythagoras formula calculate distance between 2 points. problem can not index usable. i've tried
create index indx on location(lat,lon)
also with
create index indx on location(street,lat,lon)
with no luck. i've notice when there math operation lat or lon, index not being called . there way can optimize query using index gain speed results?
thanks in advance!
the problem sql engine needs evaluate records comparison (where ..... <= ...) , filter points indexes don’t speed query. 1 approach solve problem compute minimum , maximum latitude , longitude restrict number of record. here link follow: finding points within distance of latitude/longitude
Comments
Post a Comment