Re: Spped of max - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Spped of max
Date
Msg-id 20020516010612.A14367@svana.org
Whole thread Raw
In response to Re: Spped of max  (Jean-Luc Lachance <jllachan@nsd.ca>)
List pgsql-general
On Wed, May 15, 2002 at 10:24:55AM -0400, Jean-Luc Lachance wrote:
> The real question is:
>
> Why is reltuples only an approximation?

It's only an approximation because it is updated by VACUUM. It's used to
estimate the cost of queries.

Secondly, remember that there is not really a canonical
number-of-tuples-in-a-table. If you start a transaction and insert a row,
you'll see one more row than any other transaction running at the time. If
you're using a trigger to keep a count of the total, you'll get different
answers depending on whether your trigger is deferred or not. I have no idea
what happens if the trigger is not deferred but a transaction aborts.
Deadlock?

I wish people would remember this before declaring the total number of
tuples in a table a trivial problem.

HTH,
--
Martijn van Oosterhout   <kleptog@svana.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

pgsql-general by date:

Previous
From: "Joel Burton"
Date:
Subject: Re: Using COPY
Next
From: Martijn van Oosterhout
Date:
Subject: Re: (security) Rules of thumb for escaping user input?