Rails eager loading of counts? -


Curious loading is good with the included attribute

  Post.find (: all :, I am thinking that if you can count curious loads, like I want to get the number of comments for each post, without loading all the comments. <:  

Maybe something like that < / P>

  post.fund (: all ,: included => gt; [: author, "count (comments)")  

I think I Can use count_cache columns But if this is possible then it will be really beautiful to do so in all of this.

Additional bonus points if someone can show how not only can count, but also keep some conditions , As if only the counting of the posts has been approved.

At least in MySQL, this Fast to do as two separate calls because you avoid joining me I know that this is the answer to your question. But it seems that you are trying to get better speed and

  Post.find ...  

then

  post.comments.count  

If you retrieve both of them in the same query, then faster and more memory efficient (for databases) than that.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -