Re: Implementing next 30 (or so) rows "sliding window" - Mailing list pgsql-general

From Allan Kamau
Subject Re: Implementing next 30 (or so) rows "sliding window"
Date
Msg-id ab1ea6540912081112n1b1f15c5sfc8165bce4abc404@mail.gmail.com
Whole thread Raw
In response to Implementing next 30 (or so) rows "sliding window"  (Allan Kamau <kamauallan@gmail.com>)
Responses Re: Implementing next 30 (or so) rows "sliding window"  (Jaime Casanova <jcasanov@systemguards.com.ec>)
Re: Implementing next 30 (or so) rows "sliding window"  (Scott Marlowe <scott.marlowe@gmail.com>)
List pgsql-general
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.

Allan.

On Tue, Dec 8, 2009 at 9:49 PM, Allan Kamau <kamauallan@gmail.com> wrote:
> Hi,
> I am looking for an efficient way to implement a "sliding window" view
> of the data from a query.
> I am developing a simple website and would like to provide for
> viewing(fetching) only a predetermined maximum number of records per
> page.
> For example to view 100 records with "30" as the predetermined maximum
> number of records to be fetched for any page, will require 3 page
> displays with 30 records then a fourth page display having only 10
> records.
>
> A probable solution would be to use an order by clause on unique
> field(s) in the query (and the LIMIT
> <predetermined_max_number_of_records> clause), then store the these
> unique field(s) of the first and last records records in the web
> application (maybe sent it to the client embedded in the request
> response somehow). Then reuse these values for the next query by
> placing them in the where clause with a greater than or less than
> comparison operator (use the or operator in the case where of a
> composite unique key). Then use the order by and limit as usual.
> The above solution may be limited to only subsequent page views (prev
> or next) but will not work for page skips.
>
>
> Allan.
>

pgsql-general by date:

Previous
From: Allan Kamau
Date:
Subject: Implementing next 30 (or so) rows "sliding window"
Next
From: Jaime Casanova
Date:
Subject: Re: Implementing next 30 (or so) rows "sliding window"