Re: Count(*) Question

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Peter Darley <pdarley(at)kinesis-cem(dot)com>
Cc: Pgsql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Count(*) Question
Date: 2002-05-01 00:06:56
Message-ID: 20020501100656.B21515@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Apr 30, 2002 at 04:45:33PM -0700, Peter Darley wrote:
> Friends,
> I was reading through the Rules section of the online docs, and noticed the
> following note: (* is just an abbreviation for all the attribute names of a
> relation. It is expanded by the parser into the individual attributes, so
> the rule system never sees it.)
> Does this mean that count(*) may return less than the total number of
> records if all the fields in a record are NULL?

Yes, I beleive so.

> If this is true, is there a better way to get a count of records?

I think count(1) is the common suggestion.
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Canada, Mexico, and Australia form the Axis of Nations That
> Are Actually Quite Nice But Secretly Have Nasty Thoughts About America

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Rooney 2002-05-01 02:00:32 Re: What popular, large commercial websites run PostgreSQL?
Previous Message Peter Darley 2002-04-30 23:45:33 Count(*) Question