From: Tomasz Myrta <jasiek@klaster.net>
To: Andras Kutrovics <n-drew@freemail.hu>
Cc: pgsql-sql@postgresql.org
Subject: Re: Simple SQL Question
Date: Fri, 05 Nov 2004 19:09:55 +0100
Message-ID: <418BC1F3.7080205@klaster.net> (raw)
In-Reply-To: <418BB051.6070808@freemail.hu>
References: <418BB051.6070808@freemail.hu>
> Hi All!
>
> In one of my application, I would like to implement incremental
> fetching. The problem is that I would like to run it
> from a stateless application server, so I have to tell where
> to begin fetching data. It is simple for a table which has single column
> primary key, but causes difficulties (at least for me) in
> a more-column primary key..
>
> Let say I have a table wich has the primary key: itemkey,location
>
> table1
> ------
> itemkey
> location
> ...
> --------
>
>
> select * from table1 LIMIT x
>
> gives me the first x row of the result.
> After that, I save the last value, and next time, I adjust
> the query as
>
> select * from table1 where itemkey>:lastvalue LIMIT x
Why do you complicate it so much? Everything you need is:
select * from table1 LIMIT x
select * from table1 LIMIT x OFFSET x
select * from table1 LIMIT x OFFSET 2*x
Remember to sort rows before using limit/offset.
Regards,
Tomasz Myrta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jasiek@klaster.net, n-drew@freemail.hu
Subject: Re: Simple SQL Question
In-Reply-To: <418BC1F3.7080205@klaster.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox