Re: OFFSET and LIMIT - performance - Mailing list pgsql-general

From Simon Riggs
Subject Re: OFFSET and LIMIT - performance
Date
Msg-id 1183104637.3589.70.camel@silverbirch.site
Whole thread Raw
In response to Re: OFFSET and LIMIT - performance  (David Wall <d.wall@computer.org>)
List pgsql-general
On Thu, 2007-06-28 at 11:36 -0700, David Wall wrote:
> > Network transmission costs alone would make the second way a loser.
> >
> > Large OFFSETs are pretty inefficient because the backend generates and
> > discards the rows internally ... but at least it never converts them to
> > external form or ships them to the client.  Rows beyond the LIMIT are
> > not generated at all.
> >
> Some of this would depend on the query, too, I suspect, since an ORDER
> BY would require the entire result set to be determined, sorted and then
> the limit/offset could take place.

In 8.3 a LIMIT clause will be evaluated at the same time as ORDER BY, so
that the full sort cost is avoided. This means that queries with LIMIT
are more likely to return in constant time, whether you have no ORDER
BY, an ORDER BY on an index, or an ORDER BY with no index. So indexes
specifically to provide a fast ORDER BY/LIMIT are no longer required.
Courtesy of Greg Stark.

--
  Simon Riggs
  EnterpriseDB   http://www.enterprisedb.com



pgsql-general by date:

Previous
From: "Ashish Karalkar"
Date:
Subject: Create user
Next
From: "A. Kretschmer"
Date:
Subject: Re: Create user