因此,我走了一个充满员额的论坛,希望把用户从这些职位和这些用户的角色中集中起来,以减少数据库查询的总数(看来是做事的最佳方式)
(如果情况不同,则将节省额外资金、论坛和员额。)
def show
@forum = Forum.find(params[:forum_id])
@posts = @forum.posts.includes(:user => :role).where( id = ? OR parent_post_id =? ,params[:id], params[:id])
end
The page renders, but I can t really tell by looking at the console if it s actually reducing the number of queries or not. The console appears to have a slight reduction in number of queries to the CACHE, but the Load calls holds steady. Am I doing this right?