X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 44401D1DB0A for ; Wed, 14 Apr 2004 17:42:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 96507-08 for ; Wed, 14 Apr 2004 17:42:54 -0300 (ADT) Received: from trade-india.com (ns5.trade-india.com [66.234.10.13]) by svr1.postgresql.org (Postfix) with SMTP id 56B4CD1D6CC for ; Wed, 14 Apr 2004 17:42:52 -0300 (ADT) Received: (qmail 27899 invoked from network); 14 Apr 2004 17:13:50 -0000 Received: from unknown (HELO trade-india.com) (203.145.130.142) by ns5.trade-india.com with SMTP; 14 Apr 2004 17:13:50 -0000 Message-ID: <407DA257.6010904@trade-india.com> Date: Thu, 15 Apr 2004 02:13:03 +0530 From: Rajesh Kumar Mallah User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard Huxton Cc: Postgres Performance Subject: Re: select count(*) very slow on an already vacuumed table. References: <407D7A89.60508@trade-india.com> <200404142008.58533.dev@archonet.com> In-Reply-To: <200404142008.58533.dev@archonet.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/166 X-Sequence-Number: 6466 Richard Huxton wrote: >On Wednesday 14 April 2004 18:53, Rajesh Kumar Mallah wrote: > > >>Hi >>I have .5 million rows in a table. My problem is select count(*) takes >>ages. VACUUM FULL does not help. can anyone please tell me >>how to i enhance the performance of the setup. >> >> > > > >>SELECT count(*) from eyp_rfi; >> >> > >If this is the actual query you're running, and you need a guaranteed accurate >result, then you only have one option: write a trigger function to update a >table_count table with every insert/delete to eyp_rfi. > > it is just an example. in general all the queries that involves eyp_rfi become slow. reloading the table makes the query faster. mallah. >There is loads of info on this (and why it isn't as simple as you might think) >in the archives. First though: >1. Is this the actual query, or just a representation? >2. Do you need an accurate figure or just something "near enough"? > > >