Re: Implementing next 30 (or so) rows "sliding window"

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Allan Kamau <kamauallan(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Implementing next 30 (or so) rows "sliding window"
Date: 2009-12-08 20:51:38
Message-ID: dcc563d10912081251x6b8d5aadif8c12c46a48e0874@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 8, 2009 at 12:12 PM, Allan Kamau <kamauallan(at)gmail(dot)com> wrote:
> Hi,
> I did follow the basic advise and consulted the documentation for
> "SELECT" and came across "[ FETCH { FIRST | NEXT } [ count ] { ROW |
> ROWS } ONLY]" clause which seems to satisfy my requirement.

This is a cursor, which is one of two very basic ways of doing this.
IF you have presistent objects in your app layer, you can declare a
cursor and reuse it as your user moves through the list, one page
after another. If you do not have some kind of persistence layer for
db objects, then declaring a cursor each time a user navigates to
another page won't really gain you much, and adds complexity.

In that instance offset / limit work fairly well. As another poster
mentions, it gets slow with large offsets. However, most of the time,
like in forum software, you don't go dragging to page 258 of a result
set very often, so a small delay when doing so is usually acceptable.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2009-12-08 20:59:08 Re: Counts and percentages and such
Previous Message Scott Marlowe 2009-12-08 20:46:51 Re: how to allow a sysid to be a superuser?