Re: question about count(b) where b is a custom type - Mailing list pgsql-hackers

From Tino Wildenhain
Subject Re: question about count(b) where b is a custom type
Date
Msg-id 437B3ED2.3090004@wildenhain.de
Whole thread Raw
In response to Re: question about count(b) where b is a custom type  ("Pollard, Mike" <mpollard@cincom.com>)
Responses Re: question about count(b) where b is a custom type
List pgsql-hackers
Pollard, Mike schrieb:
> If count(<col>) convert <col> to a string (an assumption that Martijn
> has cast into doubt, or perhaps shredded), then rather than convert all
> non-nulls that are not a string into a string, I was proposing
> converting the values into an int with the values 0 or 1 (0 means that
> row was null for that column, 1 means that row was not null;, since
> count(<col>) means count the non-null rows in <col>).

I'm not getting how you got this idea of count() doing any conversion?
It does not and there is nothing in the docs wich would lead to this.

> Anyway, to make a short story long.  The idea is rather than convert the
> column into a string, convert it into a value indicating whether the
> column was null or not null (which is all count cares about).  In any
> case, it's moot idea since it appears Postgres already does that.

No, count does not convert. It just counts all non null values.
If you want to count rows, just use count(*).


pgsql-hackers by date:

Previous
From: Michael Alan Dorman
Date:
Subject: Re: bind variables, soft vs hard parse
Next
From: Rod Taylor
Date:
Subject: Re: PG_DUMP and table locking in PG7.4