Very interesting read. I totally agree that for many cases the SQL alternatives benefits outweigh the performance cost.
I’m trying to use this solution wih cancancan and I’m stumbling with issues that the counts aren’t loaded in the object returned by the query.
@author = Author.with_counts.find_by id: params[:id]
raises a NoMethodError (undefined method books_count’…
Do you have any experience with this?