X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DEBF952990 for ; Fri, 8 Jul 2005 11:12:38 -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 31701-10 for ; Fri, 8 Jul 2005 14:12:30 +0000 (GMT) Received: from noao.edu (noao.edu [140.252.1.54]) by svr1.postgresql.org (Postfix) with ESMTP id 65DA352A06 for ; Fri, 8 Jul 2005 11:12:29 -0300 (ADT) X-TFF-CGPSA-Version: 1.4f1 X-TFF-CGPSA-Filter: Scanned Received: from [140.252.14.8] (HELO weaver.tuc.noao.edu) by noao.edu (CommuniGate Pro SMTP 4.3.6) with ESMTPS id 19189267; Fri, 08 Jul 2005 07:12:28 -0700 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by weaver.tuc.noao.edu (8.13.1/8.13.1) with ESMTP id j68ECQkN028104; Fri, 8 Jul 2005 07:12:27 -0700 Message-ID: <42CE89CA.2070607@noao.edu> Date: Fri, 08 Jul 2005 07:12:26 -0700 From: Steve Wampler User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Chris Browne Cc: pgsql-sql@postgresql.org Subject: Re: Make COUNT(*) Faster? References: <9EF2931D-1097-470D-8ECB-59D00166C96F@apple.com> <60vf3mklue.fsf@dba2.int.libertyrms.com> In-Reply-To: <60vf3mklue.fsf@dba2.int.libertyrms.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/69 X-Sequence-Number: 22047 Chris Browne wrote: > None of those transactions have COMMITted, so there are some 78 tuples > "in limbo" spread across 16 transactions. > > If there were some "single secret place" with a count, how would you > suggest it address those 78 tuples and 16 transactions that aren't yet > (and maybe never will be) part of the count? Hmmm, I understand this and don't doubt it, but out of curiousity, how does the current SELECT COUNT(*) handle this? It doesn't lock the entire table while counting (I assume) so the current implementation is really just an approximate count in the above scenario anyway. Or even when not, since the true 'count' is likely to have changed by the time the user does anything with the result of SELECT COUNT(*) on any active table (and on an inactive table, pg_class.reltuples is nearly as good as SELECT COUNT(*) and far faster to get to.) I assume this has been beaten well past death, but I don't see why it wouldn't be possible to keep pg_class.reltuples a bit more up-to-date instead of updating it only on vacuums. -- Steve Wampler -- swampler@noao.edu The gods that smiled on your birth are now laughing out loud.