Module: SeqScanner::QueryExplainer

Defined in:
lib/seq_scanner/query_explainer.rb

Class Method Summary collapse

Class Method Details

.explain(query) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/seq_scanner/query_explainer.rb', line 4

def explain(query)
  return false if query[:name] == "SCHEMA"
  ActiveRecord::Base.connection.unprepared_statement do
    ActiveRecord::Base.connection.exec_query("EXPLAIN #{query[:sql]}", 'SQL', query[:binds]).to_a.map do |row|
      row['QUERY PLAN']
    end
  end
end