Mathieu Schroeter <schroe...@epsitec.ch> wrote:
> Le 20.10.2010 12:32, Mathieu Schroeter a écrit :
>> I've made a small program with this output (please, look at
>> the attached C code _first_):
> 
> Mmmh.. sorry but the previous attached code has at least one error
> and some parts commented. And now I see that without EXPLAIN QUERY PLAN,
> the comparison callback is called with the second query.
> 
> There is way in order to have the second query using the index with
> ORDER BY? It is strange that it is not the case..

Think about how you, a human, would execute such a query with pencil and paper. 
There is no index on lol. So you could a) enumerate all entries in lol, b) for 
each entry look up a corresponding row in tmp using its primary key, and c) at 
the end, after the loop over lol is complete, sort all records obtained in step 
b.

Or, you could a) enumerate all records in tmp in the correct order using the 
index, and b) for each tmp record, scan through all entries in lol to see if 
the ID appears there (remember, there are no indexes on lol, full scan is the 
only option).

Which plan would you choose?
-- 
Igor Tandetnik

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

Reply via email to