Skip to content
This repository has been archived by the owner on Nov 4, 2019. It is now read-only.

Query cannot be optimized using index #14

Open
janfabry opened this issue Aug 13, 2012 · 1 comment
Open

Query cannot be optimized using index #14

janfabry opened this issue Aug 13, 2012 · 1 comment

Comments

@janfabry
Copy link

The current filterByDistanceFrom can't use an index to speed up the query. Because of the trigonometry functions, every lat-lon pair has to be evaluated to find a possible match.

I think you can help the database by specifying the bounding box too (WHERE (lon > $west_limit AND lon < $east_limit AND lat > $south_limit AND lat < $north_limit) AND ABS([trig stuff here])). A semi-smart database can then use the index to prune out the rows that don't match the first part of the query, and only execute the trig functions for the remaining candidates.

@willdurand
Copy link
Member

You're right, thanks for the tip!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants