Quoth Michele Pradella <michele.prade...@selea.com>, on 2010-09-24 10:13:59 
+0200:
>   I have an SQLite DB of about 9GB with about 2.500.000 records.
> I can't understand why the "select COUNT(*) from log" statement is 
> extremely slow, it takes me about 9-10 minutes!
> I try with:
> select COUNT(1) from logs
> select COUNT(DateTime) from logs
> same result. Have you idea of why it's so slow?

I'm not sure why this is considered "extremely slow" when iterating
the rows of that large a file.  On my PC-class hardware I measure
around 2m30s of real time copying a 9 GB file into the null device;
it's not implausible to me that on some other hardware, using SQLite
rather than a raw copy, it would take four times as long to scan.

If you're expecting the count to be stored separately and therefore to
be quickly accessible, you might use insert/remove triggers to keep
track of that yourself in a single-row auxiliary table instead.

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

Reply via email to