avoid doing count on last page
Reported by Elijah Miller | August 24th, 2007 @ 01:16 PM
I tried my hand at implementing this but the way options are parsed and shuffled around makes a bit tricky. Here's the gist:
When we get the result set, if the size of it is less than per_page, we're definitely on the last page. In that case total entries is equal to offset + size and we can safely skip the count.
This should be a improvementn on sites with many paginated areas that only have 1 page.
Comments and changes to this ticket
-
Chris Wanstrath August 24th, 2007 @ 06:11 PM
- Assigned user changed from Chris Wanstrath to Mislav
- State changed from new to open
-
Chris Wanstrath September 27th, 2007 @ 03:09 AM
- State changed from open to resolved
(from [388]) Will Paginate lazy counting! Counting is done after the SELECT, but skipped entirely if Finder figures out that this is the last page. We are talking about saving us trips to the db here. Thanks, Elijah Miller. [#92 state:resolved]
-
Elijah Miller September 27th, 2007 @ 03:20 AM
That was a bit more involved than I expected!
Thanks for the hard work!
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Everyone's favorite Ruby library for pagination of practically anything!