Re: Connection function - Mailing list psycopg

From Joe Abbate
Subject Re: Connection function
Date
Msg-id 4F6FEB90.5050608@freedomcircle.com
Whole thread Raw
In response to Re: Connection function  (Bill House <wch-tech@house-grp.net>)
List 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

psycopg by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Connection function
Next
From: Federico Di Gregorio
Date:
Subject: Re: Connection function