On Mar 11, 3:05 pm, cdubd <[email protected]> wrote:
> On Mar 11, 3:44 pm, Frederick Cheung <[email protected]>
> wrote:> On Mar 11, 12:15 pm, cdubd <[email protected]> wrote:> render
> :partial => @submission.comment_threads
>
> > > but it still makes a separate database call for each comment.
>
> > What database calls (ie what is the association that is getting loaded
> > 1 at a time ?)
>
> Here is the output to the log. You can see at the bottom, that when
> the comment partials are rendered, there is a SELECT call to the
> database for each comment.
>
What's in the _comment partial ?
Fred
> Processing SubmissionsController#show (for 127.0.0.1 at 2009-03-11
> 12:50:20) [GET]
> Parameters: {"id"=>"4-university-offers-beatles-degree"}
> Submission Columns (2.2ms) SHOW FIELDS FROM `submissions`
> Submission Load (0.9ms) SELECT * FROM `submissions` WHERE
> (`submissions`.`id` = 4)
> User Columns (3.2ms) SHOW FIELDS FROM `users`
> User Load (1.2ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Image Load (0.5ms) SELECT `images`.* FROM `images` WHERE
> (`images`.submission_id = 4)
> Comment Load (1.5ms) SELECT `comments`.* FROM `comments` WHERE
> (`comments`.`commentable_id` = 4 and `comments`.`commentable_type` =
> 'Submission') ORDER BY created_at ASC
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Rendering template within layouts/application
> Rendering submissions/show
> Rendered submissions/_submission (3.4ms)
> Comment Load (1.3ms) SELECT * FROM `comments` WHERE
> (`comments`.commentable_id = 4 AND `comments`.commentable_type =
> 'Submission' AND (`comments`.`parent_id` IS NULL)) ORDER BY created_at
> ASC
> CACHE (0.0ms) SELECT * FROM `comments` WHERE
> (`comments`.commentable_id = 4 AND `comments`.commentable_type =
> 'Submission' AND (`comments`.`parent_id` IS NULL)) ORDER BY created_at
> ASC
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> User Load (0.7ms) SELECT * FROM `users` WHERE (`users`.`id` = 3)
> Comment Load (0.9ms) SELECT * FROM `comments` WHERE
> (`comments`.`id` = 7)
> Rendered comments/_comment (62.6ms)
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Comment Load (0.8ms) SELECT * FROM `comments` WHERE
> (`comments`.`id` = 8)
> Rendered comments/_comment (33.0ms)
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Comment Load (0.8ms) SELECT * FROM `comments` WHERE
> (`comments`.`id` = 9)
> Rendered comments/_comment (46.4ms)
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Comment Load (0.9ms) SELECT * FROM `comments` WHERE
> (`comments`.`id` = 10)
> Rendered comments/_comment (33.2ms)
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Comment Load (0.9ms) SELECT * FROM `comments` WHERE
> (`comments`.`id` = 11)
> Rendered comments/_comment (32.2ms)
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Comment Load (0.8ms) SELECT * FROM `comments` WHERE
> (`comments`.`id` = 12)
> Rendered comments/_comment (33.9ms)
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Comment Load (0.8ms) SELECT * FROM `comments` WHERE
> (`comments`.`id` = 13)
> Rendered comments/_comment (33.5ms)
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Comment Load (0.8ms) SELECT * FROM `comments` WHERE
> (`comments`.`id` = 14)
> CACHE (0.0ms) SELECT * FROM `comments` WHERE (`comments`.`id` =
> 14)
> Rendered comments/_comment (32.8ms)
> CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
> Comment Load (0.8ms) SELECT * FROM `comments` WHERE
> (`comments`.`id` = 17)
> Rendered comments/_comment (32.8ms)
> Completed in 592ms (View: 371, DB: 19) | 200 OK [http://localhost/
> submissions/4-university-offers-beatles-degree]
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---