From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
---|---|
To: | runic <runic(at)gmx(dot)de> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: select count(*) performance |
Date: | 2007-08-10 11:44:21 |
Message-ID: | b42b73150708100444x76d8881fkca87772272859d8a@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On 8/8/07, runic <runic(at)gmx(dot)de> wrote:
> Hello Group,
>
> I'm new in PostgreSQL Business, therefore please forgive me a "newbie"
> Question. I have a table with ca. 1.250.000 Records. When I execute
> a "select count (*) from table" (with pgAdmin III) it takes about 40
> secs.
> I think that takes much to long. Can you please give me hints, where
> I can search for Improvements?
This is a FAQ. This operation is optimized in some other database
engines but not in PostgreSQL due to way the locking engine works.
There are many workarounds, maybe the easiest is to get an approximate
count using
select reltuples from pg_class where relname = 'your_table' and relkind = 'r';
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Brian Hurt | 2007-08-10 13:08:18 | Re: select count(*) performance |
Previous Message | Merlin Moncure | 2007-08-10 10:53:20 | Re: Dell Hardware Recommendations |