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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-performance by date

  From Date Subject
Next Message Radovan Antloga 2006-04-20 16:10:21 Re: Performance decrease
Previous Message Tom Lane 2006-04-20 15:41:41 Re: Performance decrease