X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0AFDCD1B4EF for ; Thu, 2 Oct 2003 19:16:52 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 64020-01 for ; Thu, 2 Oct 2003 16:16:03 -0300 (ADT) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id EB6E1D1B552 for ; Thu, 2 Oct 2003 16:16:01 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id DB4745FE8 for ; Thu, 2 Oct 2003 19:15:47 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h92JFl9d094291 for pgsql-performance@postgresql.org; Thu, 2 Oct 2003 12:15:47 -0700 (PDT) (envelope-from dror) Date: Thu, 2 Oct 2003 12:15:47 -0700 From: Dror Matalon To: "pgsql-performance@postgresql.org" Subject: count(*) slow on large tables Message-ID: <20031002191547.GZ87525@rlx11.zapatec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200310/58 X-Sequence-Number: 3806 Hi, I have a somewhat large table, 3 million rows, 1 Gig on disk, and growing. Doing a count(*) takes around 40 seconds. Looks like the count(*) fetches the table from disk and goes through it. Made me wonder, why the optimizer doesn't just choose the smallest index which in my case is around 60 Megs and goes through it, which it could do in a fraction of the time. Dror -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com