Railsã§ãActiveRecordãSQLã®ãã°ãåãã¦ããããã§ãããããã ã¨ã©ã®ã¯ã¨ãªãã©ãããå¼ã°ããã®ãåãããªãã¦ããããã°ããã«ããã
Schedule Load (0.023687) SELECT * FROM schedules WHERE (schedules.id = 3) LIMIT 1 Resource Load (0.001076) SELECT * FROM resources WHERE (resources.id = 328) LIMIT 1 Schedule Load (0.011488) SELECT * FROM schedules WHERE (schedules.id = 3) LIMIT 1 Resource Load (0.022471) SELECT * FROM resources WHERE (resources.id = 328) LIMIT 1
query_trace ï¼ http://rubygems.org/gems/query_trace ï¼ã¨ããã©ã¤ãã©ãªã使ãã¨ããããªé¢¨ã«ã¹ã¿ãã¯ãã¬ã¼ã¹ãåºãããã«ãªãã®ã§ããã®ã¯ã¨ãªã£ã¦ã©ãããåºã¦ããã ãï¼ ã¿ãããªã¨ãã®ãããã°ãã¨ã¦ã楽ã«ãªãã¾ãã
Schedule Load (0.023687) SELECT * FROM schedules WHERE (schedules.id = 3) LIMIT 1 app/models/available_work.rb:50:in `study_method' app/helpers/plan_helper.rb:4:in `work_description' app/views/plan/_resource_schedule.rhtml:27:in `_run_rhtml_plan__resource_schedule' app/views/plan/_resource_schedule.rhtml:24:in `_run_rhtml_plan__resource_schedule' app/views/plan/_schedule_listing.rhtml:5:in `_run_rhtml_plan__schedule_listing' app/views/plan/_schedule_listing.rhtml:3:in `_run_rhtml_plan__schedule_listing' app/views/plan/_schedule_listing.rhtml:1:in `_run_rhtml_plan__schedule_listing' app/views/plan/index.rhtml:6:in `_run_rhtml_plan_index' vendor/plugins/textmate_footnotes/lib/textmate_footnotes.rb:60:in `render' Resource Load (0.001076) SELECT * FROM resources WHERE (resources.id = 328) LIMIT 1 app/models/available_work.rb:54:in `div_type' app/helpers/plan_helper.rb:6:in `work_description' app/views/plan/_resource_schedule.rhtml:27:in `_run_rhtml_plan__resource_schedule' app/views/plan/_resource_schedule.rhtml:24:in `_run_rhtml_plan__resource_schedule' app/views/plan/_schedule_listing.rhtml:5:in `_run_rhtml_plan__schedule_listing' app/views/plan/_schedule_listing.rhtml:3:in `_run_rhtml_plan__schedule_listing' app/views/plan/_schedule_listing.rhtml:1:in `_run_rhtml_plan__schedule_listing' app/views/plan/index.rhtml:6:in `_run_rhtml_plan_index' vendor/plugins/textmate_footnotes/lib/textmate_footnotes.rb:60:in `render' :
ã¤ã³ã¹ãã¼ã«
2010/10/11ç¾å¨ã query_trace ã®ææ°ãã¼ã¸ã§ã³ã¯ 0.1.1 ãªãã§ãããããã ã¨ã¾ã Rails3ã«å¯¾å¿ãã¦ããªãã®ã§ãgithubããæ°ããã³ããããåã£ã¦ãããã¨ã«ãã¾ãã
Gemfileã«ä»¥ä¸ã追è¨ãã¦ã bundle install ã
gem 'query_trace', :git => 'http://github.com/dolzenko/query_trace.git', :ref=>'0e142a25c76816002da7'
ãã¡ããã 0.1.1 以éããªãªã¼ã¹ããã¦ããã°ããã¡ãã使ãã®ãããã§ãããã
使ãæ¹
rails serverèµ·åæã«ãç°å¢å¤æ° QUERY_TRACE=true ãè¨å®ããã ãã§OKã§ãã
$ QUERY_TRACE=true script/rails server
ãããã¯ã config/initializers/ 以ä¸ãããã«
QueryTrace.enable!
ã¨æ¸ããåæåãã¡ã¤ã«ãç½®ãã¦ããã¾ãã
ããã ãã§ãæåã«ç´¹ä»ãããããªãã¬ã¼ã¹ãåºãããã«ãªãã¾ããRails3ã¯Arelã®é
延ã¯ã¨ãªæ©è½ããããããã§ãæãã¬ã¨ããã§ã¯ã¨ãªãçºè¡ãããããã¾ããã¡ãªã®ã§ãéçºæã¯æ®æ®µãããã¬ã¼ã¹ãåºãã¦ããã¨è²ã
çºè¦ãããããã§ããã