Thread: Re: [HACKERS] Much Ado About COUNT(*)

Re: [HACKERS] Much Ado About COUNT(*)

From
"Dann Corbit"
Date:
A cardinality estimate function might be nice.
SELECT cardinality_estimate(table_name)
If it is off by 25% then no big deal.
It would be useful for the PostgreSQL query planner also, I imagine.

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Wes
Sent: Friday, January 14, 2005 2:59 PM
To: Postgres general mailing list
Subject: Re: [GENERAL] [HACKERS] Much Ado About COUNT(*)

On 1/14/05 12:47 PM, "Frank D. Engel, Jr." <fde101@fjrhome.net> wrote:

> It's probably too messy to be worthwhile this
> way, though.  More trouble than it would be worth.

It would be rather useful if there was a way to get a reasonably
accurate
count (better than analyze provides) in a very short period.  When
you've
got a relatively wide table that has hundreds of millions to over a
billion
rows, and you need to report on how many rows in the table, that can
take a
long time.

Wes



---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Re: [HACKERS] Much Ado About COUNT(*)

From
Martijn van Oosterhout
Date:
On Fri, Jan 14, 2005 at 03:11:32PM -0800, Dann Corbit wrote:
> A cardinality estimate function might be nice.
> SELECT cardinality_estimate(table_name)
> If it is off by 25% then no big deal.
> It would be useful for the PostgreSQL query planner also, I imagine.

If that's all you want, what about the row estimate from pg_class? It
has the number of rows active at last vacuum... For really large tables
I imagine it'd be easily close enough...

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

Re: [HACKERS] Much Ado About COUNT(*)

From
Wes
Date:
On 1/14/05 5:37 PM, "Martijn van Oosterhout" <kleptog@svana.org> wrote:

> If that's all you want, what about the row estimate from pg_class? It
> has the number of rows active at last vacuum... For really large tables
> I imagine it'd be easily close enough...

For showing the changes in a given day (or even week), that isn't accurate
enough.

Wes