Module: ActiveRecord::ConnectionAdapters::MySQL::DatabaseStatements
- Included in:
- AbstractMysqlAdapter
- Defined in:
- lib/active_record/connection_adapters/mysql/database_statements.rb
Instance Method Summary collapse
- #build_explain_clause(options = []) ⇒ Object
- #explain(arel, binds = [], options = []) ⇒ Object
- #high_precision_current_timestamp ⇒ Object
-
#write_query?(sql) ⇒ Boolean
:nodoc:.
Instance Method Details
#build_explain_clause(options = []) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/active_record/connection_adapters/mysql/database_statements.rb', line 36 def build_explain_clause( = []) return "EXPLAIN" if .empty? explain_clause = "EXPLAIN #{.join(" ").upcase}" if analyze_without_explain? && explain_clause.include?("ANALYZE") explain_clause.sub("EXPLAIN ", "") else explain_clause end end |
#explain(arel, binds = [], options = []) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/active_record/connection_adapters/mysql/database_statements.rb', line 27 def explain(arel, binds = [], = []) sql = build_explain_clause() + " " + to_sql(arel, binds) start = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = internal_exec_query(sql, "EXPLAIN", binds) elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start MySQL::ExplainPrettyPrinter.new.pp(result, elapsed) end |
#high_precision_current_timestamp ⇒ Object
23 24 25 |
# File 'lib/active_record/connection_adapters/mysql/database_statements.rb', line 23 def HIGH_PRECISION_CURRENT_TIMESTAMP end |
#write_query?(sql) ⇒ Boolean
:nodoc:
17 18 19 20 21 |
# File 'lib/active_record/connection_adapters/mysql/database_statements.rb', line 17 def write_query?(sql) # :nodoc: !READ_QUERY.match?(sql) rescue ArgumentError # Invalid encoding !READ_QUERY.match?(sql.b) end |