Check here: https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/view_helpers.rb#L140
In the first case you use collection.size and in the second case you use collection.total_entries. The latter one has the workaround for the "group by case", while the former does not. I guess if you use total_entries in both situations everything will be fine. Until then, the workaround in applications would be to do:
collection = Table.paginate(...).all
That way ActiveRecord's size does not issue a select count. Instead it counts the rows fetched.
use `total_entries` in page_entries_info() consistently
Fixes #278, fixes #284, fixes #207