Hey everyone, I am working on an application that allows users to submit articles, and also comment on those articles. Pretty much exactly like Digg. Everything works fine except that when there are a lot of comments there are a lot of database queries to both fetch the comments and the users who posted those comments. I have used eager loading in other parts of my application to reduce the amount of database queries, but when I apply the same practices in this situation it doesn't seem to work. Here is what I am working with:
I am using the "acts_as_commentable_with_threading" plugin that I forked from elight on github http://github.com/elight/acts_as_commentable_with_threading/tree/master the association that is created is as follows class Submission < ActiveRecord::Base has_many :comment_threads, :class_name => "Comment", :as => :commentable, :dependent => :destroy, :order => 'created_at ASC' end So Submission has many comment_threads.... using this association I tried to implement eager loading like this: def show @submission = Submission.find(params[:id], :include => {:comment_threads => :user}) end I tried it without the hash, and just the comment_threads as well In the view, I am rendering the comment partials by calling render :partial => @submission.comment_threads but it still makes a separate database call for each comment. Anything obvious I am doing wrong hear? I am getting a bit frustrated because a simple page with 15 comments loads 2X more slowly than a submissions page that has images, and many other things going on with it. Thanks for the help! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

