From: | Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> |
---|---|
To: | Shridhar Daithankar <shridhar_daithankar(at)persistent(dot)co(dot)in> |
Cc: | Postgresql Performance <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Select max(foo) and select count(*) optimization |
Date: | 2004-01-06 16:03:23 |
Message-ID: | 1073405003.20751.2.camel@camel |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Tue, 2004-01-06 at 07:20, Shridhar Daithankar wrote:
> On Tuesday 06 January 2004 17:48, D'Arcy J.M. Cain wrote:
> > On January 6, 2004 01:42 am, Shridhar Daithankar wrote:
> > cert=# select relpages,reltuples::bigint from pg_class where relname=
> > 'certificate';
> > relpages | reltuples
> > ----------+-----------
> > 399070 | 24858736
> > (1 row)
> >
> > But:
> >
> > cert=# select count(*) from certificate;
> > [*Crunch* *Crunch* *Crunch*]
> > count
> > ----------
> > 19684668
> > (1 row)
> >
> > Am I missing something? Max certificate_id is 20569544 btw.
>
> Do 'vacuum analyze certificate' and try..:-)
>
> The numbers from pg_class are estimates updated by vacuum /analyze. Of course
> you need to run vacuum frequent enough for that statistics to be updated all
> the time or run autovacuum daemon..
>
> Ran into same problem on my machine till I remembered about vacuum..:-)
>
Actually you only need to run analyze to update the statistics.
Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL
From | Date | Subject | |
---|---|---|---|
Next Message | Shridhar Daithankar | 2004-01-06 16:31:20 | Re: Select max(foo) and select count(*) optimization |
Previous Message | Clive Page | 2004-01-06 15:40:48 | Inefficient SELECT with OFFSET and LIMIT |