From: | Ragnar Hafstað <gnari(at)simnet(dot)is> |
---|---|
To: | Joel Fradkin <jfradkin(at)wazagua(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: getting count for a specific querry |
Date: | 2005-04-08 16:25:46 |
Message-ID: | 1112977546.7447.39.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Sullivan | 2005-04-08 16:30:39 | Re: getting count for a specific querry |
Previous Message | Ragnar Hafstað | 2005-04-08 16:17:45 | Re: getting count for a specific querry |