Re: Questions about LIMIT/OFFSET

From: Josh Trutwin <josh(at)trutwins(dot)homeip(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Questions about LIMIT/OFFSET
Date: 2007-10-20 00:11:31
Message-ID: 20071019191131.09a9841b@prokofiev.trutwins.homeip.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 19 Oct 2007 18:19:55 -0500
Michael Glaesemann <grzm(at)seespotcode(dot)net> wrote:

>
> On Oct 19, 2007, at 16:03 , Josh Trutwin wrote:
>
> > SELECT * FROM table WHERE foo="bar" ORDER BY abc LIMIT x OFFSET y;
>
> The server will have to generate at most OFFSET + LIMIT rows,
> returning LIMIT rows or fewer.
>
> > SELECT * FROM table WHERE foo="bar" ORDER BY abc;
>
> This will return all of the rows available.
>
> Unless you're going to be returning all of the rows where
> foo="bar" (e.g., executing multiple LIMIT OFFSET queries) in one
> request, I should think the first query would be more performant:
> fewer rows for the server to process (in the final step at least)
> and less data transmitted between the server and your application.

Thanks - server and application are on the same box so not as big a
concern, but this is the way I decided to go for the time being.

Josh

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-10-20 00:59:11 Re: Question regarding Hibernate ORDER BY issue
Previous Message Ralph Smith 2007-10-19 23:38:28 Connection & logging Problems