On 2 Oct 2015, at 9:05am, Bart Smissaert <bart.smissaert at gmail.com> wrote:

> Noticed that if I have table with a unique index on all fields, counting
> all rows is still a lot faster
> (about a factor 10 on my particular test table) than counting distinct rows.
> Could maybe an optimization be added to SQLite to speed this up, taking
> advantage of the fact that there is a unique index on all fields?

The fact that your index is so wide is actually slowing it down.  Because it 
means that the index takes up more space on disk.  The fastest way to count all 
the rows in a table would be to have an index on just a single numeric field.  
This means that reading the whole index in would involve reading the least 
number of pages.

Simon.

Reply via email to