title: How to get total result set size on a group_by count query?
body: <p>I have the following query within my model:</p>
  
  <pre><code>Post.where("created_utc &gt; ? AND lower(category) = ?", 0, 'videos').group(:domain).order('count_all desc').page(1).per(25).count
  </code></pre>
  
  <p>I'm using the <code>kaminari</code> gem for pagination but the problem is this: this query returns what appears to be a sorted hash. However I have no way of knowing what the total result count is.</p>
  
  <p>If you prefer not to take <code>kaminari</code> into consideration, you can reference the following query:</p>
  
  <pre><code>Post.where("created_utc &gt; ? AND lower(category) = ?", min_time, subreddit.downcase).group(:domain).order('count_all desc').limit(limit).offset(start).count
  </code></pre>
  
  <p>Regardless, I have no way of figuring out what the total number of results is. How can I go about resolving this? Is there some way to figure out what the total result set size would be without the limit?</p>