From: Merlin Moncure <mmoncure@gmail.com>
To: runic <runic@gmx.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: select count(*) performance
Date: Fri, 10 Aug 2007 17:14:21 +0530
Message-ID: <b42b73150708100444x76d8881fkca87772272859d8a@mail.gmail.com> (raw)
In-Reply-To: <1186578085.034463.116030@q75g2000hsh.googlegroups.com>
References: <1186578085.034463.116030@q75g2000hsh.googlegroups.com>
On 8/8/07, runic <runic@gmx.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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: mmoncure@gmail.com, runic@gmx.de
Subject: Re: select count(*) performance
In-Reply-To: <b42b73150708100444x76d8881fkca87772272859d8a@mail.gmail.com>
References: <1186578085.034463.116030@q75g2000hsh.googlegroups.com> <b42b73150708100444x76d8881fkca87772272859d8a@mail.gmail.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