| 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 | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Federico Di Gregorio | 2012-03-26 07:52:02 | Re: Connection function | 
| Previous Message | Adrian Klaver | 2012-03-26 01:58:31 | Re: Connection function |