Skip to content

Instantly share code, notes, and snippets.

@nicedawg
Created March 5, 2020 05:36
Show Gist options
  • Save nicedawg/cfe9422f14763cbf831a224d7c74b8c5 to your computer and use it in GitHub Desktop.
Save nicedawg/cfe9422f14763cbf831a224d7c74b8c5 to your computer and use it in GitHub Desktop.
[Beginning Rails 6] Listing 11-12. No more N+1 queries when loading articles
Started GET "/" for ::1 at 2020-03-04 23:27:15 -0600
Processing by ArticlesController#index as HTML
Rendering articles/index.html.erb within layouts/application
Article Load (0.2ms) SELECT "articles".* FROM "articles"
↳ app/views/articles/index.html.erb:4
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" IN (?, ?) [["id", 2], ["id", 1]]
↳ app/views/articles/index.html.erb:4
ActionText::RichText Load (0.4ms) SELECT "action_text_rich_texts".* FROM "action_text_rich_texts"...
↳ app/views/articles/index.html.erb:4
ActiveStorage::Attachment Load (0.3ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments"...
↳ app/views/articles/index.html.erb:4
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
↳ app/controllers/application_controller.rb:6:in `current_user'
Rendered collection of articles/_article.html.erb [4 times] (Duration: 12.5ms | Allocations: 3421)
Rendered articles/index.html.erb within layouts/application (Duration: 24.7ms | Allocations: 7684)
[Webpacker] Everything's up-to-date. Nothing to do
Completed 200 OK in 36ms (Views: 32.9ms | ActiveRecord: 1.5ms | Allocations: 13062)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment