From: Jim C. Nasby <jnasby@pervasive.com>
To: G?briel ?kos <akos.gabriel@i-logic.hu>
Cc: pgsql-performance@postgresql.org
Subject: Re: count(*) performance
Date: Mon, 27 Mar 2006 07:41:04 -0600
Message-ID: <20060327134103.GI80726@pervasive.com> (raw)
In-Reply-To: <4427E9E8.9030806@i-logic.hu>
References: <4427E9E8.9030806@i-logic.hu>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: jnasby@pervasive.com, akos.gabriel@i-logic.hu
Subject: Re: count(*) performance
In-Reply-To: <20060327134103.GI80726@pervasive.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox