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 6427852AD6 for ; Fri, 8 Jul 2005 13:12:33 -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 91628-06 for ; Fri, 8 Jul 2005 16:12:29 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id EE99C52ABB for ; Fri, 8 Jul 2005 13:12:25 -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 j68GCNMt023284; Fri, 8 Jul 2005 12:12:24 -0400 (EDT) To: Steve Wampler Cc: pgsql-sql@postgresql.org Subject: Re: Make COUNT(*) Faster? In-reply-to: <42CEA305.1050904@noao.edu> References: <9EF2931D-1097-470D-8ECB-59D00166C96F@apple.com> <60vf3mklue.fsf@dba2.int.libertyrms.com> <42CE89CA.2070607@noao.edu> <20050708143508.GD22725@wolff.to> <42CE96AF.3020903@noao.edu> <22916.1120836900@sss.pgh.pa.us> <42CEA305.1050904@noao.edu> Comments: In-reply-to Steve Wampler message dated "Fri, 08 Jul 2005 09:00:05 -0700" Date: Fri, 08 Jul 2005 12:12:23 -0400 Message-ID: <23283.1120839143@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/83 X-Sequence-Number: 22061 Steve Wampler writes: > Tom Lane wrote: >> If you want something cheap, you could use the same technique the >> planner uses nowadays: take RelationGetNumberOfBlocks() (which is >> guaranteed accurate) and multiply by reltuples/relpages. > Yes - this would be an excellent approximation for my needs! The > solution that Dawid Kuroczko suggested (just call "explain select * > on ..." and parse the result) would be equivalent these days, right? Close enough (the planner actually does some additional heuristic stuff to avoid going crazy on corner cases). regards, tom lane