On Wed, Sep 6, 2017 at 7:56 AM, Hick Gunter <h...@scigames.at> wrote:

> Count(<name>) needs to extract the <name> field from the record, tallying
> only those that are NOT NULL.
>

Technically it would not need to "extract" the <name> field, only lookup
the row header and
see whether that field/column is NULL or not (since NULL is a special
SERIAL TYPE of value 0 [1]).

asql> explain select count(a) from t;
> addr  opcode         p1    p2    p3    p4             p5  comment
> ----  -------------  ----  ----  ----  -------------  --  -------------
> ...
> 4     OpenRead       0     2     1     1              00  t
> 5     Rewind         0     9     0                    00  NULL
> 6     Column         0     0     3                    00  t.a
> 7     AggStep        0     3     1     count(1)       01  NULL
> ...
>

But as you showed, in practice it may still do, because of the Column VDBE
op-code.
Unless one imagines a specialized ColumnNullness of ColumnType new op-code
that
wouldn't need to extract the actual value/content, as a future
optimization. --DD

[1] https://www.sqlite.org/fileformat.html#record_format
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to