3 ms·
That's awfully handy. It unfortunately doesn't solve the pagination problem, though. :/
by cheald 15y ago
That's awfully handy. It unfortunately doesn't solve the pagination problem, though. :/
- taf2 15y agoit does, if you change your pagination interface to only care if there are more results after this page...
- cheald 15y agoIf your pagination interface is simply "Next", then why not skip the count all together, limit(N+1) documents, and offer the "Next" button if the result set is N+1 large?
- kevin1024 15y agoBy the way, if you do .limit() / .offset() pagination, by the time you get into really high offsets, queries will start going slow again. Mongo has to do a scan up to the document at offset that you are asking for.
- josh_cutler 15y agoI forked a version of Kaminari a few months ago to solve this problem for me that I just updated with the latest upstream: https://github.com/joshcutler/kaminari https://github.com/joshcutler/kaminari I added a class method for Mongoid::Documents called limit_max_count_results_to that limits the size of Kaminari's total_count