pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: D'Arcy J.M. Cain <darcy@druid.net>
To: Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
To: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: Select max(foo) and select count(*) optimization
Date: Tue, 6 Jan 2004 17:57:05 -0500
Message-ID: <200401061757.05278.darcy@druid.net> (raw)
In-Reply-To: <200401061750.09530.shridhar_daithankar@persistent.co.in>
References: <BC1F1F20.71370%siracusa@mindspring.com>
	<200401060718.08444.darcy@druid.net>
	<200401061750.09530.shridhar_daithankar@persistent.co.in>

On January 6, 2004 07:20 am, 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..:-)

Kind of invalidates the part about being accurate then, don't it?  Besides, I 
vacuum that table every day (*) and we have reorganized the schema so that we 
never update it except in exceptional cases.  I would be less surprised if 
the result was less than the real count since we only insert into that table.

In any case, if I have to vacuum a 20,000,000 row table to get an accurate 
count then I may as well run count(*) on it.

(*): Actually I only analyze but I understand that that should be sufficient.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.



view thread (19+ messages)  latest in thread

Message-ID: <200401061757.05278.darcy@druid.net>
Permalink:  ../200401061757.05278.darcy@druid.net/
Also on:    postgresql.org/message-id/200401061757.05278.darcy@druid.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: darcy@druid.net, shridhar_daithankar@persistent.co.in
  Subject: Re: Select max(foo) and select count(*) optimization
  In-Reply-To: <200401061757.05278.darcy@druid.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox