Skip site navigation (1) Skip section navigation (2)

Re: Takes too long to fetch the data from database

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "soni de" <soni(dot)de(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Takes too long to fetch the data from database
Date: 2006-04-20 16:05:02
Message-ID: b42b73150604200905h56a0d387xec8c80b4c8d3e901@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
> 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

In response to

Responses

pgsql-performance by date

Next:From: Radovan AntlogaDate: 2006-04-20 16:10:21
Subject: Re: Performance decrease
Previous:From: Tom LaneDate: 2006-04-20 15:41:41
Subject: Re: Performance decrease

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group