Received: from mail2.uniserve.com (mail2.uniserve.com [204.244.156.10]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3BHqf825577 for ; Wed, 11 Apr 2001 13:52:41 -0400 (EDT) (envelope-from gutz@kalador.com) Received: from van12d24.dial.uniserve.ca ([204.244.161.87] helo=gutz) by mail2.uniserve.com with smtp (Exim 3.13 #1) id 14nOnH-0004as-00 for pgsql-sql@postgresql.org; Wed, 11 Apr 2001 10:52:40 -0700 From: "Gerald Gutierrez" To: Subject: Making SELECT COUNT(seed) FROM fast Date: Wed, 11 Apr 2001 10:58:42 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Archive-Number: 200104/162 X-Sequence-Number: 2510 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.