Re: Much Ado About COUNT(*)

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Much Ado About COUNT(*)
Date: 2005-01-12 21:20:43
Message-ID: 20050112212043.GA2137@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-hackers pgsql-patches

On Wed, Jan 12, 2005 at 13:42:58 -0700,
"Jonah H. Harris" <jharris(at)tvi(dot)edu> wrote:
> We seem to be in agreement. I'm looking for faster/smarter access to
> data, not the monetary cost of doing so. Isn't it faster/smarter to
> satisfy a query with the index rather than sequentially scanning an
> entire relation if it is possible?

Not necessarily. Also note that Postgres will use an index scan for
count(*) if there is a relatively selective WHERE clause.

> Replying to the list as a whole:
>
> If this is such a bad idea, why do other database systems use it? As a
> businessperson myself, it doesn't seem logical to me that commercial
> database companies would spend money on implementing this feature if it
> wouldn't be used. Remember guys, I'm just trying to help.

Other databases use different ways of handling tuples that are only visible
to some concurrent transactions.

Postgres is also flexible enough that you can make your own materialized
view (using triggers) to handle count(*) if that makes sense for you.

In response to

Responses

Browse pgsql-announce by date

  From Date Subject
Next Message Jonah H. Harris 2005-01-12 21:36:55 Re: Much Ado About COUNT(*)
Previous Message Jeff Davis 2005-01-12 21:17:57 Re: Much Ado About COUNT(*)

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonah H. Harris 2005-01-12 21:36:55 Re: Much Ado About COUNT(*)
Previous Message Jeff Davis 2005-01-12 21:17:57 Re: Much Ado About COUNT(*)

Browse pgsql-patches by date

  From Date Subject
Next Message Jonah H. Harris 2005-01-12 21:36:55 Re: Much Ado About COUNT(*)
Previous Message Jeff Davis 2005-01-12 21:17:57 Re: Much Ado About COUNT(*)