Class: ActiveRecord::ExplainSubscriber
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activerecord/lib/active_record/explain_subscriber.rb |
Constant Summary
-
EXPLAINED_SQLS =
# File 'activerecord/lib/active_record/explain_subscriber.rb', line 24/\A\s*(\/\*.*\*\/)?\s*(with|select|update|delete|insert)\b/i
-
IGNORED_PAYLOADS =
SCHEMA queries cannot be EXPLAINed, also we do not want to run EXPLAIN on our own EXPLAINs no 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)
Instance Method Summary
Instance Method Details
#finish(name, id, payload)
[ GitHub ]# File 'activerecord/lib/active_record/explain_subscriber.rb', line 12
def finish(name, id, payload) if ExplainRegistry.collect? && !ignore_payload?(payload) ExplainRegistry.queries << payload.values_at(:sql, :binds) end end
#ignore_payload?(payload) ⇒ Boolean
# File 'activerecord/lib/active_record/explain_subscriber.rb', line 25
def ignore_payload?(payload) payload[:exception] || payload[:cached] || IGNORED_PAYLOADS.include?(payload[:name]) || !payload[:sql].match?(EXPLAINED_SQLS) end
#start(name, id, payload)
[ GitHub ]# File 'activerecord/lib/active_record/explain_subscriber.rb', line 8
def start(name, id, payload) # unused end