2017-09-05 23:11 GMT+02:00 Simon Slavin <slav...@bigfraud.org>:

> On 5 Sep 2017, at 9:21pm, Cecil Westerhof <cldwester...@gmail.com> wrote:
> > I want to know the number of teas I have in stock. For this I use:
> > FROM   teaInStock
> >
> > Tea cannot be NULL, so this is the same as:
> > FROM   teaInStock
> >
> > ​But I find the first more clear.
> > I almost always see the second variant. Is this because it is more
> > efficient, or are people just ‘lazy’?​
> Your guess is right !
> To do COUNT(*) SQLite has to retrieve all the rows.
> To do COUNT(value) has to retrieve all the rows and test the value of each
> row to make sure it is not NULL.
> Also, SQLite has a specific piece of code which makes COUNT(*) more
> efficient than counting the values.  However, unless you have a big
> database, the difference for your case may be small.  If you find
> COUNT(Tea) easier to understand perhaps you should use that one.

​I will keep using COUNT(Tea) then, but keep in the back of my mind that I
maybe should change that if a table becomes big.


Cecil Westerhof
sqlite-users mailing list

Reply via email to