On 19 Oct 2013, at 7:29pm, Raheel Gupta <raheel...@gmail.com> wrote:

> My current index is actually in the correct order of my query.
> I use 'n' and 's' and they are the first in the query.

This isn't how SQLite works.  It's more clever than that.  SQlite will analyze 
your WHERE clause and do lots of clever chopping up and rearranging to try to 
find the best index for the fastest and most efficient operation.  The order 
that you specify your requirements in the WHERE clause is ignored.  What's 
important is that you provide an index which lets SQLite give you the results 
efficiently.

One way to figure out the best query is to make lots of indexes in different 
orders, then do an ANALYZE (thank you Fabien), then to use EXPLAIN QUERY PLAN 
to find which index SQLite prefers for your SELECT.  Once you know the one it 
likes you can delete the others to save space.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to