amatsuda/kaminari — pull request #484 by camallen (2013-12-05 13:26:50+00:00)
Title: use the mongoid criteria #length method to cache the count of the collection per collection

Fixes slow pagination into large mongoid collections as the criteria method doesn't cache the count. `ActionViewExtension#page_entries_info` calls total_count 3 or 4 times (depending on execution path), slowing the view render.

http://mongoid.org/en/mongoid/docs/querying.html
`Criteria#length`, Also size. Get a count of persisted documents. After being called once for the criteria, will cache subsequent calls and not hit the database.