X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C91C511F719C for ; Tue, 11 Apr 2006 07:17:37 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.126 X-Spam-Level: X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id s+xt8JsP0cv7 for ; Tue, 11 Apr 2006 07:17:24 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by postgresql.org (Postfix) with ESMTP id 524CF11F6AAD for ; Tue, 11 Apr 2006 07:17:22 -0300 (ADT) Received: from [213.162.97.75] (helo=mail.metronet.co.uk) by ptb-relay02.plus.net with esmtp (Exim) id 1FTFvo-00063Z-TI; Tue, 11 Apr 2006 11:17:08 +0100 Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id F31477364F; Tue, 11 Apr 2006 11:18:40 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 060F415EA4; Tue, 11 Apr 2006 11:17:02 +0100 (BST) Message-ID: <443B821D.2000005@archonet.com> Date: Tue, 11 Apr 2006 11:17:01 +0100 From: Richard Huxton User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: soni de Cc: "Joshua D. Drake" , Rajesh Kumar Mallah , pgsql-performance@postgresql.org Subject: Re: Takes too long to fetch the data from database References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> <443AA1D4.9010308@commandprompt.com> <9f2e40a90604110005o101fe98enec2f8ac8f757c770@mail.gmail.com> In-Reply-To: <9f2e40a90604110005o101fe98enec2f8ac8f757c770@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200604/231 X-Sequence-Number: 18315 soni de wrote: > I have flushed the database, so currently records in the "lan" table are: > 665280 > > but records can be increased more than 1GB and in that case it takes more > than 1 hour > > Below is explain analyze output taken from the table having 665280 records > > pdb=# explain analyze SELECT sdate, stime, rbts from lan WHERE ( > ( bname = 'pluto' ) AND ( cno = 17 ) AND ( pno = 1 ) AND ( ( sdate > >= '2004-07-21' ) AND ( sdate <= '2004-07-21' ) ) ) ORDER BY sdate, stime > ; > > NOTICE: QUERY PLAN: > Sort (cost=17.13..17.13 rows=1 width=16) (actual time=619140.18..619140.29rows > =288 loops=1) > -> Index Scan using lan_pkey on lan (cost=0.00..17.12 rows=1 width=16) > (actual time=7564.44..619121.61 rows=288 loops=1) > > Total runtime: 619140.76 msec OK - there is clearly something wrong here when you take 10 minutes to fetch 288 rows from an index. 1. VACUUM FULL VERBOSE lan; 2. test again, and if that doesn't work... 3. REINDEX TABLE lan; 4. test again I'm guessing you have a *lot* of dead rows in there. -- Richard Huxton Archonet Ltd