module Pagy::ArelExtra
def pagy_arel_count(collection)
def pagy_arel_count(collection) if collection.group_values.empty? # COUNT(*) collection.count(:all) else # COUNT(*) OVER () sql = Arel.star.count.over(Arel::Nodes::Grouping.new([])) collection.unscope(:order).limit(1).pluck(sql).first.to_i end end