I have a current implementation of will_paginate that uses the paginate_by_sql method to build the collection to be paginated. We have a custom query for total_entries that's very complicated and puts a large load on our DB. Therefore we would like to cut total_entries from the pagination altogether.
In other words, instead of the typical pagination display of 'previous 1 [2] 3 4 5 next', we would simply like a 'next - previous' button only. But we need to know a few things.
- Do we display the previous link? This would only occur of course if records existing prior to the ones displayed in the current selection
- Do we display the next link? This would not be displayed if the last record in the collection is being displayed
From the docs
A query for counting rows will automatically be generated if you don’t supply :total_entries. If you experience problems with this generated SQL, you might want to perform the count manually in your application.
So ultimately the ideal situation is the following.
- Remove the total_entries count because it's causing too much load on the database
- Display 50 records at a time with semi-pagination using only next/previous buttons to navigate and not needing to display all page numbers available
- Only display the next button and previous button accordingly
Has anyone worked with a similar issue or have thoughts on a resolution?