module ArJdbc::MSSQL::ExplainSupport
Constants
- DISABLED
Public Instance Methods
explain(arel, binds = [])
click to toggle source
# File lib/arjdbc/mssql/explain_support.rb, line 11 def explain(arel, binds = []) return if DISABLED sql = to_sql(arel, binds) result = with_showplan_on { exec_query(sql, 'EXPLAIN', binds) } PrinterTable.new(result).pp end
supports_explain?()
click to toggle source
# File lib/arjdbc/mssql/explain_support.rb, line 9 def supports_explain?; ! DISABLED; end
Protected Instance Methods
set_showplan_option(enable = true)
click to toggle source
# File lib/arjdbc/mssql/explain_support.rb, line 27 def set_showplan_option(enable = true) option = 'SHOWPLAN_TEXT' execute "SET #{option} #{enable ? 'ON' : 'OFF'}" rescue Exception => e raise ActiveRecord::ActiveRecordError, "#{option} could not be turned" + " #{enable ? 'ON' : 'OFF'} (check SHOWPLAN permissions) due : #{e.inspect}" end
with_showplan_on() { || ... }
click to toggle source
# File lib/arjdbc/mssql/explain_support.rb, line 20 def with_showplan_on set_showplan_option(true) yield ensure set_showplan_option(false) end