On Fri, 2005-04-08 at 09:29 -0400, Joel Fradkin wrote:
> Our app currently pulls a bunch of data to several query pages.
>
> My idea is to use the limit and offset to return just the first 50
> records, if they hit next I can set the offset.
>
> My understanding was this gets slower as you move further into the
> data, but we have several options to modify the search, and I do not
> believe our clients will page very far intro a dataset.
you might reduce the performance loss if your dataset is ordered by
a UNIQUE index.
select * from mytable where somecondition ORDER by uniquecol limit 50;
and next:
select * from mytable where somecondition AND uniquecol>? ORDER by uniquecol limit 50 OFFSET 50;
where the ? is placeholder for last value returned by last query.
if your unique index is a multi-column one, the method is slightly
more complicated, but the same idea.
gnari