disable explain in Rails 3.2

南笙酒味 提交于 2019-12-20 10:33:26

问题


Is it possible to disable the new the explain functionality in Rails 3.2 globally via configuration? I'm using activerecord-sqlserver-adapter 3.2.1 and there appear to be some bugs with the explain (show plan) portion of the gem.


回答1:


To cite from http://weblog.rubyonrails.org/2011/12/6/what-s-new-in-edge-rails-explain/

New applications get

config.active_record.auto_explain_threshold_in_seconds = 0.5

in config/environments/development.rb. Active Record monitors queries and if they take more than that threshold their query plan will be logged using warn.

[...]

By default the threshold is nil in the test and production environments, which means the feature is disabled.

so just set

config.active_record.auto_explain_threshold_in_seconds = nil



回答2:


You can disable auto-explain by setting config.active_record.auto_explain_threshold_in_seconds = nil in your config/environments/development.rb




回答3:


You should note that config.auto_explain_threshold_in_seconds has been completely removed in Rails 4.0 & 4.1. In 4.1 it will throw a full error.

See https://github.com/rails/rails/pull/9400/files

If you upgrade, comment that line out.



来源:https://stackoverflow.com/questions/9777203/disable-explain-in-rails-3-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!