Class: ActiveRecord::ExplainSubscriber

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/explain_subscriber.rb

Overview

:nodoc:

Constant Summary collapse

IGNORED_PAYLOADS =

SCHEMA queries cannot be EXPLAINed, also we do not want to run EXPLAIN on our own EXPLAINs now matter how loopingly beautiful that would be.

On the other hand, we want to monitor the performance of our real database queries, not the performance of the access to the query cache.

%w(SCHEMA EXPLAIN CACHE)

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object



5
6
7
8
9
10
# File 'activerecord/lib/active_record/explain_subscriber.rb', line 5

def call(*args)
  if queries = Thread.current[:available_queries_for_explain]
    payload = args.last
    queries << payload.values_at(:sql, :binds) unless ignore_payload?(payload)
  end
end

#ignore_payload?(payload) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'activerecord/lib/active_record/explain_subscriber.rb', line 18

def ignore_payload?(payload)
  payload[:exception] || IGNORED_PAYLOADS.include?(payload[:name])
end