pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: soni de <soni.de@gmail.com>
To: Merlin Moncure <mmoncure@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Takes too long to fetch the data from database
Date: Fri, 21 Apr 2006 10:12:24 +0530
Message-ID: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> (raw)
In-Reply-To: <b42b73150604200905h56a0d387xec8c80b4c8d3e901@mail.gmail.com>
References: <9f2e40a90604100021n1cb694d0lb95f318f800f33ee@mail.gmail.com>
	<b42b73150604100845w553dcee6kde20e4b82770aab0@mail.gmail.com>
	<9f2e40a90604110004u787716c2s22bdf53fe349326@mail.gmail.com>
	<b42b73150604110613h2c63ea61oec8035c8e2f4ed98@mail.gmail.com>
	<9f2e40a90604192237i5d3e8f0dl1c8b19887bc34e22@mail.gmail.com>
	<b42b73150604200905h56a0d387xec8c80b4c8d3e901@mail.gmail.com>

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).

if we fetched sequentially, there is also problem in fetching all the
records (select * from wan where kname='pluto' order by stime) it is taking
more than 4~5 minutes. tried it on same table having more than 326054
records.


On 4/20/06, Merlin Moncure <mmoncure@gmail.com> wrote:
>
> > SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900;
>
> you need to try and solve the problem without using 'offset'.  you could
> do:
> BEGIN;
> DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime;
> FETCH ABSOLUTE 81900 in crs;
> FETCH 49 in crs;
> CLOSE crs;
> COMMIT;
>
> this may be a bit faster but will not solve the fundamental problem.
>
> the more interesting question is why you want to query exactly 81900
> rows into a set.  This type of thinking will always get you into
> trouble, absolute positioning will not really work in a true sql
> sense.  if you are browsing a table sequentially, there are much
> better methods.
>
> merlin
>

view thread (17+ messages)  latest in thread

Message-ID: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com>
Permalink:  ../9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com/
Also on:    postgresql.org/message-id/9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: soni.de@gmail.com, mmoncure@gmail.com
  Subject: Re: Takes too long to fetch the data from database
  In-Reply-To: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox