Re: [SQL] OFFSET impact on Performance??? - Mailing list pgsql-performance

From Richard Huxton
Subject Re: [SQL] OFFSET impact on Performance???
Date
Msg-id 41EFCC5B.5010302@archonet.com
Whole thread Raw
In response to Re: [SQL] OFFSET impact on Performance???  ("Andrei Bintintan" <klodoma@ar-sd.net>)
Responses Re: [SQL] OFFSET impact on Performance???
Re: [SQL] OFFSET impact on Performance???
List pgsql-performance
Andrei Bintintan wrote:
>> If you're using this to provide "pages" of results, could you use a
>> cursor?
>
> What do you mean by that? Cursor?
>
> Yes I'm using this to provide "pages", but If I jump to the last pages
> it goes very slow.

DECLARE mycursor CURSOR FOR SELECT * FROM ...
FETCH FORWARD 10 IN mycursor;
CLOSE mycursor;

Repeated FETCHes would let you step through your results. That won't
work if you have a web-app making repeated connections.

If you've got a web-application then you'll probably want to insert the
results into a cache table for later use.

--
   Richard Huxton
   Archonet Ltd

pgsql-performance by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: PostgreSQL clustering VS MySQL clustering
Next
From: Dave Cramer
Date:
Subject: Re: PostgreSQL clustering VS MySQL clustering