X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2943FD1B484 for ; Tue, 6 Jan 2004 06:44:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 07249-10 for ; Tue, 6 Jan 2004 02:43:18 -0400 (AST) Received: from smtp.pspl.co.in (unknown [202.54.11.65]) by svr1.postgresql.org (Postfix) with ESMTP id 4CA28D1B483 for ; Tue, 6 Jan 2004 02:43:11 -0400 (AST) Received: (from root@localhost) by smtp.pspl.co.in (8.12.9/8.12.9) id i066hMU6028871 for ; Tue, 6 Jan 2004 12:13:22 +0530 Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) (authenticated bits=0) by persistent.co.in (8.12.9/8.12.9) with ESMTP id i066hLJN028849 for ; Tue, 6 Jan 2004 12:13:22 +0530 From: Shridhar Daithankar To: Postgresql Performance Subject: Re: Select max(foo) and select count(*) optimization Date: Tue, 6 Jan 2004 12:12:21 +0530 User-Agent: KMail/1.5.4 References: <1073332325.8958.8.camel@jester> In-Reply-To: <1073332325.8958.8.camel@jester> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200401061212.21344.shridhar_daithankar@persistent.co.in> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/63 X-Sequence-Number: 5238 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=; Assuming the stats are recent enough, it would be much faster and accurate.. Shridhar