optimization - Should I create an index on the columns if their values are used in functions ? (SQLite) -


I am working with a huge database and am trying to optimize it at the top.

I was wondering if this

for example I have this GPS coordinate table:

  -node (for example) # ID, latitude, LNG)  

and request this:

  SELECT * FROM node WHERE distance (lat, lng, $ lat, $ lng) & lt ; $ Threshold  

Want to optimize any of Latitude and LNG? (I am working with SQLite)

thanks

edit I thought about the same question, but if I calculate directly :

SELECT * FROM node WHERE (lat- $ lat) * (lat- $ lat) + (lng- $ lng) * (lng- $ lng) & lt; $ Threshold

The database needs to be calculated in the distance for each node in your example And will not benefit from an index if you index the LNG and the Late column and use it to eliminate all the nodes in advance, which you have in the stomach (lat - $ lat)> $ threshold or stomach ( LNG - $ lng)> $ thresholds, because you can see more performance than the database The

query something like this:

  SELECT * FROM node WHERE lat & Gt; = $ Latitude - $ range and latitude & lt; = $ Latitude + $ threshold and lng & gt; = $ Lng - $ range and LNG & lt; = $ Lng + $ threshold and distance (latitude, lng, $ lat, $ lng) & lt; $ Range;  

Comments