I have been working on fixing a piece of code for a customer that has been very slow for them.
I have made that fix, and thats all lovely, but I noticed something odd in the paging.
When the query is executed, it does NOT contain a
LIMIT keyword. Then, based on the per-page value and the current page the viewer is on, the result reader is told to fetch from the index of the Record at
(perPage * currentPage - 1) to the Record at
(perPage * currentPage) - 1, and the total number of Records the result has are used to determine the total number of pages.
So, are there any benefits doing it this way as opposed to using the
LIMIT keyword, and a separate
COUNT(*) query (possibly only done once per search context)?