As @Fivell pointed out, even after #2333 we're still hitting the database to get a count of all records, which is expensive if you have millions of records. This time around, it's an issue with Kaminari itself.
Specifically, we call paginate which ends up calling total_pages.
This has apparently been a long-standing issue with Kaminari, and some people have suggested fixes, but no one has yet submitted an actual pull request.
Another reference: http://engineering.nulogy.com/posts/avoiding-redundant-counting/
As @Fivell pointed out, even after #2333 we're still hitting the database to get a count of all records, which is expensive if you have millions of records. This time around, it's an issue with Kaminari itself.
Specifically, we call
paginatewhich ends up callingtotal_pages.This has apparently been a long-standing issue with Kaminari, and some people have suggested fixes, but no one has yet submitted an actual pull request.
Another reference: http://engineering.nulogy.com/posts/avoiding-redundant-counting/