No, whether the column contains a null is irrelevant. It is whether the column CAN contain a null.
> -----Original Message----- > From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users- > bounces at mailinglists.sqlite.org] On Behalf Of Bart Smissaert > Sent: Friday, 2 October, 2015 11:15 > To: General Discussion of SQLite Database > Subject: Re: [sqlite] Speed of count distinct rows if unique index on all > fields > > OK, thanks. > Do you mean that is only valid if there are no rows where all columns are > NULL? > In any case, I can see that this optimization (in SQLite) is just not > worth > the trouble. > > RBS > > > On Fri, Oct 2, 2015 at 6:02 PM, Richard Hipp <drh at sqlite.org> wrote: > > > On 10/2/15, Bart Smissaert <bart.smissaert at gmail.com> wrote: > > > > > > Unless I am mistaken here this is done with a SQL like this: > > > > > > SELECT COUNT(*) AS UNIQUE_ROWS > > > FROM (SELECT DISTINCT * FROM TABLE1) > > > > > > But if we take advantage of the fact that this table has a unique > index > > on > > > all the fields of the table > > > we can simply do this SQL: > > > > > > SELECT COUNT(*) FROM TABLE1 > > > > > > > No. That is only valid if all columns are individually NOT NULL. > > > > -- > > D. Richard Hipp > > drh at sqlite.org > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users at mailinglists.sqlite.org > > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > > > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users