Re: Make COUNT(*) Faster?

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Make COUNT(*) Faster?
Date: 2005-07-08 15:31:00
Message-ID: 20050708153100.GC21449@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Jul 08, 2005 at 08:07:27AM -0700, Steve Wampler wrote:
> Bruno Wolff III wrote:
> > No, it is an exact count.
>
> Yes, for the transaction, but it's an approximation of the number of
> tuples in the table - which is probably what the people who worry about
> its cost are more interested in (an approximate count for the table).

You seem to have the wrong idea of "tuples in the table" here. You
need to think harder about MVCC visibility rules. Given MVCC,
there isn't really a "view from nowhere" in the system -- there's
just the idea of what tuple visibility. For a little more, you might
want to look at the presentation Tom Lane made for this:

http://www.postgresql.org/files/developer/transactions.pdf

A

--
Andrew Sullivan | ajs(at)crankycanuck(dot)ca
A certain description of men are for getting out of debt, yet are
against all taxes for raising money to pay it off.
--Alexander Hamilton

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Dawid Kuroczko 2005-07-08 15:34:27 Re: Make COUNT(*) Faster?
Previous Message Dawid Kuroczko 2005-07-08 15:30:35 Re: Make COUNT(*) Faster?