Method: NewRelic::Agent::Database::ExplainPlanHelpers#process_explain_results_mysql

Defined in:
lib/new_relic/agent/database/explain_plan_helpers.rb

#process_explain_results_mysql(results) ⇒ Object

[View source]

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/new_relic/agent/database/explain_plan_helpers.rb', line 97

def process_explain_results_mysql(results)
  headers = []
  values = []
  if results.is_a?(Array)
    # We're probably using the jdbc-mysql gem for JRuby, which will give
    # us an array of hashes.
    headers = results.first.keys
    results.each do |row|
      values << headers.map { |h| row[h] }
    end
  else
    # We're probably using the native mysql driver gem, which will give us
    # a Mysql::Result object that responds to each_hash
    results.each_hash do |row|
      headers = row.keys
      values << headers.map { |h| row[h] }
    end
  end
  [headers, values]
end