How to Count With ActiveRecord
you should almost always use size when counting ActiveRecord relations. It will usually choose the most efficient way to count: a length on the array if you’ve already loaded the records, a speedy COUNT query if you haven’t, or simply reading from the available counter cache if you don’t need to.
Source: work.stevegrossi.com