Dennis Cote wrote:
> Alexey Pechnikov wrote:
>> I think, you can use index directly as
>> create index id_idx on mytable(id);
>>
>> select count(id) from mytable where id>0;
>>
>> explain query plan select count(id) from mytable where id>0;
>> 0|0|TABLE mytable WITH INDEX id_idx
>>
>> It's better than use count(*) with "where" condition.
> 
> I can't see how this improves the situation any. You are making SQLite 
> do a full scan of the index (assuming all records have an id > 0) 
> instead of a full scan of the table. It still has to count each record.

Well if the index requires fewer page reads then it should be 
proportionally faster. For example if you can only get 5 rows on a page 
but 25 index entries, you have 1/5 the number of pages to read.

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

Reply via email to