Re: question about count(b) where b is a custom type

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: "Pollard, Mike" <mpollard(at)cincom(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: question about count(b) where b is a custom type
Date: 2005-11-16 14:14:42
Message-ID: 437B3ED2.3090004@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(*).

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2005-11-16 14:31:51 Re: PG_DUMP and table locking in PG7.4
Previous Message Michael Alan Dorman 2005-11-16 13:58:52 Re: bind variables, soft vs hard parse