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

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

From: "Spiegelberg, Greg" <gspiegelberg(at)cranel(dot)com>
To: 'Richard Huxton' <dev(at)archonet(dot)com>,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 18:04:02
Message-ID: 387C22290D3FD71195D300508BF7DB5238B017@colmail01.cranel.local (view raw or flat)
Thread:
Lists: pgsql-performancepgsql-sql
Isn't this a prime example of when to use a servlet or something similar
in function?  It will create the cursor, maintain it, and fetch against
it for a particular page.

Greg


-----Original Message-----
From: Richard Huxton [mailto:dev(at)archonet(dot)com]
Sent: Thursday, January 20, 2005 10:21 AM
To: Andrei Bintintan
Cc: pgsql-sql(at)postgresql(dot)org; pgsql-performance(at)postgresql(dot)org
Subject: Re: [PERFORM] [SQL] OFFSET impact on 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

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
      message can get through to the mailing list cleanly

pgsql-performance by date

Next:From: Bruno Almeida do LagoDate: 2005-01-20 18:09:57
Subject: Re: PostgreSQL clustering VS MySQL clustering
Previous:From: Ron MayerDate: 2005-01-20 18:03:17
Subject: Re: PostgreSQL vs. Oracle vs. Microsoft

pgsql-sql by date

Next:From: Ragnar HafstaĆ°Date: 2005-01-20 19:12:06
Subject: Re: [SQL] OFFSET impact on Performance???
Previous:From: Richard HuxtonDate: 2005-01-20 17:44:09
Subject: Re: ERROR: row is too big: size 9856, maximum size 8136

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