I have a SQLite table t1 with three columns, c1, c2 and c3 with a composite index on (c1, c2). I want to run the following query:
Select max(c2) from t1 where c1=Value and c3 not like "abcd%".
Now, it can use the composite index to filter only those records with c1 matching the Value and apply where condition for c3 then pick the record with max(c2).
Or it can use the full composite index to filter all record with c1 matching the Value and walk c2 in reverse (descending order) and then compare the where condition.
The second approach will be faster in my case.
The question is how does SQLLite optimize this query: First one or Second one?
EXPLAIN QUERY PLAN <query>