X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id E78CB11F66EC for ; Fri, 21 Apr 2006 14:39:10 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -2.588 X-Spam-Level: X-Spam-Status: No, score=-2.588 required=5 tests=[AWL=0.011, BAYES_00=-2.599] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id h1Tz0MuUic6z for ; Fri, 21 Apr 2006 14:39:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from wolff.to (wolff.to [66.93.197.194]) by postgresql.org (Postfix) with SMTP id CD3BE11F6D59 for ; Fri, 21 Apr 2006 14:39:01 -0300 (ADT) Received: (qmail 18236 invoked by uid 500); 21 Apr 2006 17:41:49 -0000 Date: Fri, 21 Apr 2006 12:41:49 -0500 From: Bruno Wolff III To: soni de Cc: Merlin Moncure , pgsql-performance@postgresql.org Subject: Re: Takes too long to fetch the data from database Message-ID: <20060421174149.GA13275@wolff.to> Mail-Followup-To: Bruno Wolff III , soni de , Merlin Moncure , pgsql-performance@postgresql.org References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com> <9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com> <9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com> <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> User-Agent: Mutt/1.4.2.1i X-Archive-Number: 200604/507 X-Sequence-Number: 18591 On Fri, Apr 21, 2006 at 10:12:24 +0530, soni de wrote: > I don't want to query exactly 81900 rows into set. I just want to fetch 50 > or 100 rows at a time in a decreasing order of stime.(i.e 50 or 100 rows > starting from last to end). You can do this efficiently, if stime has an index and you can deal with using stime from the previous query instead of the record count. The idea is to select up 50 or 100 records in descending order where the stime is <= the previous stime. This can give you some overlapping records, so you need some way to deal with this.