On 11 Nov 2011, at 7:27pm, Tim Streater wrote: > select count(status) from mytable where status=0; > select count(status) from mytable where status=0 limit 1; > select status from mytable where status=0 limit 1; > > When doing this a number of times I see some seconds of CPU being taken; I > haven't yet pinned it down to being an SQLite problem - I'm about to do some > timings to see where the time is going. I've added an index: > > create index stat on mytable (status asc); > > and using the third form above together with an index seems to improve > matters a bit.
The index is definitely going to improve this tremendously. I like your third form from the above: try to get just one line, and see whether you get one line or none. I think it'll work best. But you might want to compare its speed with select count(*) from mytable where status=0 The 'count(*)' expression gets treated specially. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users