Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-performance by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group