Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicate line numbers. Fixes #366. #368

Merged
merged 1 commit into from Nov 18, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions source/topics/performance/queries.markdown
Expand Up @@ -154,15 +154,15 @@ Note that the `EXPLAIN` runs after the original query, which was already slow, s
Another way to improve the total time of a request is to reduce the number of queries being made. This is accomplished by selecting more data in a single query instead of executing multiple queries. In the [Measuring Performance]({% page_url measuring %}) section, we looked at this log snippet: Another way to improve the total time of a request is to reduce the number of queries being made. This is accomplished by selecting more data in a single query instead of executing multiple queries. In the [Measuring Performance]({% page_url measuring %}) section, we looked at this log snippet:


```text ```text
1 Started GET "/articles/1" for 127.0.0.1 at 2011-09-12 13:07:21 -0400 Started GET "/articles/1" for 127.0.0.1 at 2011-09-12 13:07:21 -0400
2 Processing by ArticlesController#show as HTML Processing by ArticlesController#show as HTML
3 Parameters: {"id"=>"1"} Parameters: {"id"=>"1"}
4 Article Load (0.3ms) SELECT "articles".* FROM "articles" WHERE "articles"."id" = 1 LIMIT 1 Article Load (0.3ms) SELECT "articles".* FROM "articles" WHERE "articles"."id" = 1 LIMIT 1
5 Tag Load (0.3ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags".id = "taggings".tag_id WHERE (("taggings".article_id = 1)) Tag Load (0.3ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags".id = "taggings".tag_id WHERE (("taggings".article_id = 1))
6 SQL (0.2ms) SELECT COUNT(*) FROM "comments" WHERE ("comments".article_id = 1) SQL (0.2ms) SELECT COUNT(*) FROM "comments" WHERE ("comments".article_id = 1)
7 Comment Load (0.2ms) SELECT "comments".* FROM "comments" WHERE ("comments".article_id = 1) Comment Load (0.2ms) SELECT "comments".* FROM "comments" WHERE ("comments".article_id = 1)
8 Rendered articles/show.html.erb within layouts/application (102.8ms) Rendered articles/show.html.erb within layouts/application (102.8ms)
9 Completed 200 OK in 124ms (Views: 106.7ms | ActiveRecord: 1.0ms) Completed 200 OK in 124ms (Views: 106.7ms | ActiveRecord: 1.0ms)
``` ```


The purpose of the show action is to display an article, but the way our page is setup it's kicking off queries against `articles`, `tags`, and `comments` tables. The purpose of the show action is to display an article, but the way our page is setup it's kicking off queries against `articles`, `tags`, and `comments` tables.
Expand Down Expand Up @@ -486,4 +486,4 @@ Then, to try it out:
* https://github.com/zilkey/active_hash * https://github.com/zilkey/active_hash
* http://api.rubyonrails.org/classes/ActiveRecord/Base.html * http://api.rubyonrails.org/classes/ActiveRecord/Base.html
* http://guides.rubyonrails.org/association_basics.html#belongs_to-counter_cache * http://guides.rubyonrails.org/association_basics.html#belongs_to-counter_cache
* ActiveRecord Query Interface: http://guides.rubyonrails.org/active_record_querying.html * ActiveRecord Query Interface: http://guides.rubyonrails.org/active_record_querying.html