X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C939E9DCA7E for ; Mon, 27 Mar 2006 09:41:02 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61794-03 for ; Mon, 27 Mar 2006 09:41:06 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id 9E79B9DC99E for ; Mon, 27 Mar 2006 09:41:00 -0400 (AST) Received: by noel.decibel.org (Postfix, from userid 1001) id 919BE56427; Mon, 27 Mar 2006 07:41:04 -0600 (CST) Received: (hashcash-sendmail, from uid 1001); Mon, 27 Mar 2006 07:41:04 -0600 Date: Mon, 27 Mar 2006 07:41:04 -0600 From: "Jim C. Nasby" To: G?briel ?kos Cc: pgsql-performance@postgresql.org Subject: Re: count(*) performance Message-ID: <20060327134103.GI80726@pervasive.com> References: <4427E9E8.9030806@i-logic.hu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4427E9E8.9030806@i-logic.hu> X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Hashcash: 1:20:060327:akos.gabriel@i-logic.hu::h2jPYZbuxDxqMlCR:00000000000000 0000000000000000000000003FFg X-Hashcash: 1:20:060327:pgsql-performance@postgresql.org::UZ3Mi4kJZHbBetFW:00000 0000000000000000000000003o78 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.109 required=5 tests=[AWL=0.109] X-Spam-Score: 0.109 X-Spam-Level: X-Archive-Number: 200603/519 X-Sequence-Number: 17956 On Mon, Mar 27, 2006 at 03:34:32PM +0200, G?briel ?kos wrote: > Hi, > > I guess this is an age-old 100times answered question, but I didn't find > the answer to it yet (neither in the FAQ nor in the mailing list archives). > > Question: I have a table with 2.5M rows. count(*) on this table is > running 4 minutes long. (dual opteron, 4gig ram, db on 4 disk raid10 > array (sata, not scsi)) Is this normal? How could I make it run faster? > Maybe make it run faster for the 2nd time? Which parameters should I > change in postgresql.conf and how? First, count(*) on PostgreSQL tends to be slow because you can't do index covering[1]. But in this case, I'd bet money that if it's taking 4 minutes something else is wrong. Have you been vacuuming that table frequently enough? What's SELECT relpages FROM pg_class WHERE relname='tablename' show? [1] http://www.pervasive-postgres.com/lp/newsletters/2006/Insights_postgres_Feb.asp#5 -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461