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

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

From: Ragnar Hafstað <gnari(at)simnet(dot)is>
To: pgsql-performance(at)postgresql(dot)org
Cc: Andrei Bintintan <klodoma(at)ar-sd(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] OFFSET impact on Performance???
Date: 2005-01-20 19:23:12
Message-ID: 1106248992.22416.25.camel@localhost.localdomain (view raw, whole thread or download thread mbox)
Lists: pgsql-performancepgsql-sql
On Thu, 2005-01-20 at 19:12 +0000, Ragnar Hafstað wrote:
> On Thu, 2005-01-20 at 11:59 -0500, Greg Stark wrote:
> > The best way to do pages for is not to use offset or cursors but to use an
> > index. This only works if you can enumerate all the sort orders the
> > application might be using and can have an index on each of them.
> > 
> > To do this the query would look something like:
> > 
> > SELECT * FROM tab WHERE col > ? ORDER BY col LIMIT 50
> > 
> > Then you take note of the last value used on a given page and if the user
> > selects "next" you pass that as the starting point for the next page.
> this will only work unchanged if the index is unique. imagine , for
> example if you have more than 50 rows with the same value of col.
> one way to fix this is to use ORDER BY col,oid

and a slightly more complex WHERE clause as well, of course


In response to


pgsql-performance by date

Next:From: Merlin MoncureDate: 2005-01-20 19:29:34
Subject: Re: [SQL] OFFSET impact on Performance???
Previous:From: Steve WamplerDate: 2005-01-20 19:13:17
Subject: Re: PostgreSQL clustering VS MySQL clustering

pgsql-sql by date

Next:From: Tom LaneDate: 2005-01-20 20:38:07
Subject: Re: ERROR: row is too big: size 9856, maximum size 8136
Previous:From: Ragnar HafstaðDate: 2005-01-20 19:12:06
Subject: Re: [SQL] OFFSET impact on Performance???

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