X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B658753661 for ; Thu, 14 Apr 2005 08:28:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06398-09 for ; Thu, 14 Apr 2005 11:28:11 +0000 (GMT) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id 19D8D5361F for ; Thu, 14 Apr 2005 08:28:10 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 4.42) id 1DM2W0-000GZN-Cq; Thu, 14 Apr 2005 11:28:11 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 5A66117A37; Thu, 14 Apr 2005 12:28:07 +0100 (BST) Message-ID: <425E53C7.5080604@archonet.com> Date: Thu, 14 Apr 2005 12:28:07 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andreas Joseph Krogh Cc: pgsql-sql@postgresql.org Subject: Re: Very low performance on table with only 298 rows References: <200504141248.21783.andreak@officenet.no> In-Reply-To: <200504141248.21783.andreak@officenet.no> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.059 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/186 X-Sequence-Number: 21079 Andreas Joseph Krogh wrote: > nbeweb=> EXPLAIN select count(*) from onp_web_index; > QUERY PLAN > ----------------------------------------------------------------------------- > Hi all. > I have a problem with a table which only has 298 rows in it. A select count(*) > takes forever and CTRL-C also takes a long time canceling the query. There > are only 298 rows in the table when count(*) returns. How come it takes such > a long time counting only 298 rows? Here is EXPLAIN ANALYZE: > > nbeweb=> EXPLAIN ANALYZE select count(*) from onp_web_index; > QUERY PLAN > ----------------------------------------------------------------------------------------------------------------------------------- > Aggregate (cost=205759.52..205759.52 rows=1 width=0) (actual > time=179748.910..179748.913 rows=1 loops=1) > -> Seq Scan on onp_web_index (cost=0.00..205455.41 rows=121641 width=0) > (actual time=179735.956..179747.821 rows=298 loops=1) > Total runtime: 179748.993 ms Why does PG think you have 121641 rows in this table? How often do you vacuum it? How often do you analyse it? Does "vacuum full verbose" show a lot of dead rows being removed? I'm suspecting a *lot* of dead rows need to be removed. -- Richard Huxton Archonet Ltd