Pavel Ivanov a écrit :
>> It seems to me the DB engine tries to perform an unindexed search if the
>> requested value is not present in the index.
>> Is this behaviour intended ? How can I get rid of it ?
>>     
>
> If your index is in that very order as you said, i.e. (utc,
> id_client), then whatever @IdClient you put in the query SQLite will
> perform full index scan because it can benefit from index only for the
> purpose of ordering but not for the purpose of searching. You've just
> got lucky having LIMIT 1 in the query and providing @IdClient that has
> some utc close to maximum. If you provide @IdClient that has utc close
> to minimum then you'll get long execution time again. But if you
> change your index to (id_client, utc) then you'll have fast times for
> any @IdClient.
>
>   
That make perfectly sense, thank you very much !
I didn't imagine the fields' order could be important but I can clearly 
see now.

This might not be the scope of sqlite.org documentation area, but it 
could be a good idea to have a paper about how indexes work.

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

Reply via email to