X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2C734DA508 for ; Fri, 7 Oct 2005 10:42:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03717-09 for ; Fri, 7 Oct 2005 13:42:27 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3127FDA56E for ; Fri, 7 Oct 2005 10:42:29 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j97DgWXt003255; Fri, 7 Oct 2005 09:42:32 -0400 (EDT) To: "Cestmir Hybl" Cc: pgsql-performance@postgresql.org Subject: Re: count(*) using index scan in "query often, update rarely" environment In-reply-to: <935801c5cb20$dcf93a00$131fc39e@stratos> References: <935801c5cb20$dcf93a00$131fc39e@stratos> Comments: In-reply-to "Cestmir Hybl" message dated "Fri, 07 Oct 2005 11:24:05 +0200" Date: Fri, 07 Oct 2005 09:42:32 -0400 Message-ID: <3254.1128692552@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/142 X-Sequence-Number: 14910 "Cestmir Hybl" writes: > Isn't it possible (and reasonable) for these environments to keep track = > of whether there is a transaction in progress with update to given table = > and if not, use an index scan (count(*) where) or cached value = > (count(*)) to perform this kind of query? Please read the archives before bringing up such well-discussed issues. There's a workable-looking design in the archives (pghackers probably) for maintaining overall table counts in a separate table, with each transaction adding one row of "delta" information just before it commits. I haven't seen anything else that looks remotely attractive. regards, tom lane