Re: [SQL] OFFSET impact on Performance???

From: Richard Huxton <dev(at)archonet(dot)com>
To: Andrei Bintintan <klodoma(at)ar-sd(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-performance(at)postgresql(dot)org
Subject: Re: [SQL] OFFSET impact on Performance???
Date: 2005-01-20 15:20:59
Message-ID: 41EFCC5B.5010302@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance pgsql-sql

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Hervé Piedvache 2005-01-20 15:23:17 Re: PostgreSQL clustering VS MySQL clustering
Previous Message Merlin Moncure 2005-01-20 15:16:21 Re: PostgreSQL clustering VS MySQL clustering

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-01-20 16:32:30 Re: ERROR: row is too big: size 9856, maximum size 8136
Previous Message Achilleus Mantzios 2005-01-20 15:08:53 Re: pg_user relationship does not exist