Skip site navigation (1) Skip section navigation (2)

Re: Connection function

From: Joe Abbate <jma(at)freedomcircle(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Re: Connection function
Date: 2012-03-26 04:07:44
Message-ID: 4F6FEB90.5050608@freedomcircle.com (view raw or flat)
Thread:
Lists: psycopg
On 03/25/2012 09:00 PM, Bill House wrote:
> Regarding the statistics, I have since learned that the command:
> 
>     select reltuples from pg_class where relname = 'your_file_name';
> 
> Will give a record count.  I don't know how well it will keep up in a
> dynamic environment but it's a start.

reltuples "is only an estimate used by the planner."  See
http://www.postgresql.org/docs/9.1/static/catalog-pg-class.html

So if you want a more or less accurate count of rows at that given point
in time, then you should not depend on it.

As for the optimization of SELECT count(*) which Adrian had mentioned,
it's a 9.2 feature (as a result of index-only scans).  See
https://wiki.postgresql.org/wiki/Todo under Cache Usage.

Joe

In response to

psycopg by date

Next:From: Federico Di GregorioDate: 2012-03-26 07:52:02
Subject: Re: Connection function
Previous:From: Adrian KlaverDate: 2012-03-26 01:58:31
Subject: Re: Connection function

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group