From: Gerald Gutierrez <gutz@kalador.com>
To: pgsql-sql@postgresql.org
Subject: Making SELECT COUNT(seed) FROM fast
Date: Wed, 11 Apr 2001 10:58:42 -0700
Message-ID: <IIEOKIIOJMELMIFMMEBFCEDMCBAA.gutz@kalador.com> (raw)
Hi all.
I have a table with about 5 million rows in it. I need to be able to get the
exact number of rows in the table at runtime. So I tried the following:
xxx=> explain select count(seed) from mytable;
NOTICE: QUERY PLAN:
Aggregate (cost=103152.27..103152.27 rows=1 width=4)
-> Seq Scan on mytable(cost=0.00..89756.42 rows=5358342 width=4)
EXPLAIN
xxx=>
Actually executing this query takes about 2 minutes on a P3-800MHz machine
with 512MB of RAM.
I have an index on the seed table, and I have done VACUUM ANALYZE on the
table after inserting the rows. Is there any way I can get this to be fast?
Thanks.
Gerald.
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-sql@postgresql.org
Cc: gutz@kalador.com
Subject: Re: Making SELECT COUNT(seed) FROM fast
In-Reply-To: <IIEOKIIOJMELMIFMMEBFCEDMCBAA.gutz@kalador.com>
References: <IIEOKIIOJMELMIFMMEBFCEDMCBAA.gutz@kalador.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