Skip site navigation (1) Skip section navigation (2)

Re: count(*) performance

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: G?briel ?kos <akos(dot)gabriel(at)i-logic(dot)hu>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: count(*) performance
Date: 2006-03-27 13:41:04
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
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?

Jim C. Nasby, Sr. Engineering Consultant      jnasby(at)pervasive(dot)com
Pervasive Software    work: 512-231-6117
vcard:       cell: 512-569-9461

In response to


pgsql-performance by date

Next:From: luchotDate: 2006-03-27 14:25:25
Subject: Query parallelism
Previous:From: Gábriel ÁkosDate: 2006-03-27 13:34:32
Subject: count(*) performance

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group