Re: Select max(foo) and select count(*) optimization

From: Shridhar Daithankar <shridhar_daithankar(at)persistent(dot)co(dot)in>
To: Postgresql Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Select max(foo) and select count(*) optimization
Date: 2004-01-06 06:42:21
Message-ID: 200401061212.21344.shridhar_daithankar@persistent.co.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tuesday 06 January 2004 01:22, Rod Taylor wrote:
> Anyway, with Rules you can force this:
>
> ON INSERT UPDATE counter SET tablecount = tablecount + 1;
>
> ON DELETE UPDATE counter SET tablecount = tablecount - 1;

That would generate lot of dead tuples in counter table. How about

select relpages,reltuples from pg_class where relname=<tablename>;

Assuming the stats are recent enough, it would be much faster and accurate..

Shridhar

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message CoL 2004-01-06 11:51:13 Re: Select max(foo) and select count(*) optimization
Previous Message Shridhar Daithankar 2004-01-06 06:31:53 Re: Select max(foo) and select count(*) optimization