From: | "Simon Riggs" <simon(at)2ndquadrant(dot)com> |
---|---|
To: | <d(dot)wall(at)computer(dot)org> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: OFFSET and LIMIT - performance |
Date: | 2007-06-29 08:10:37 |
Message-ID: | 1183104637.3589.70.camel@silverbirch.site |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2007-06-29 08:23:37 | Re: Create user |
Previous Message | Ashish Karalkar | 2007-06-29 08:01:03 | Create user |