Marian Aldenhoevel wrote:
> Hi,
>
> SELECT COUNT(*) FROM sometable;
>
> Takes 10 seconds on my testcase (340.000 rows, Database on CF, dead slow
> CPU).
>
> Is there a quicker way? Does SQLLite maybe store the total number of
> records somewhere else?
>
> The table only ever grows, there are now DELETEs on it ever, apart from
> complete truncations now and then. Can the number of rows be estimated
> from a total table size?
>
> Ciao, MM
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
Depending on your setup and depending on how often you need to query the
count you could trade off a higher INSERT time for a lightning fast
count by using a trigger. Just create a second table holding only a
single column with a single row which holds the value of the count.
Every time you insert a row you can increment that value - thus you get
a very cheap and fast count any time you want, but your INSERTs will
slow down.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users