Re: paging results in large resultsets: mysql vs postgresql?
| From: | tedd | Date: | Thu, 15 Jun 2006 17:09:14 +0000 |
| Subject: | Re: paging results in large resultsets: mysql vs postgresql? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238111@lists.php.net to get a copy of this message | ||
At 11:11 AM -0500 6/15/06, D. Dante Lorenso wrote:
>I can't seem to find the equivalent of it in PostgreSQL! The only options I see are:
>
> 1.
>
> TWO queries. The first query will perform a SELECT COUNT(*) ...; and the second query
> performs the actualy SELECT ... LIMIT x OFFSET y;
>
>-snip-
>
>I hate having to write 2 queries to get one set of data ... especially when those queries start
>getting complex.
I do exactly number 1 in http://ancientstones.com/catalog.php
Keep in mind that the first query will tell you how many record are in that specific sort and then
the second will present just those items. You have to work out the pageNumber, maxPageNumber, and
numberOfPages and then it's simple.
If you're concerned about the complexity of the query, then it makes sense to break it down to
simpler steps.
You should see the back-end of my site where if you are give a specific item, then where do you
place it in a page given the user's search criteria. It made for an interesting exorcise.
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com