Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-enable Rails 4 auto-EXPLAIN

Automatic EXPLAIN on slow-running SQL queries. This feature has been removed from Rails 4.

config.active_record.auto_explain_threshold_in_seconds = 0.5

We find it useful, in controlled circumstances. I came up short in searching for answers to the following questions.

  1. What was the underlying rationale for removing auto-EXPLAIN?
    (I'm sure the reasons are sound, but I can't find what they are.)

  2. Is there a way to reintroduce auto-EXPLAIN in my Rails 4 codebase?
    (Couldn't find a gem, nor any online information)

like image 814
changingrainbows Avatar asked Aug 28 '13 21:08

changingrainbows


1 Answers

Here is the commit that removed auto_explain. Looks like the reasoning is that it was rarely used and slightly problematic w/ the asset pipeline. As the commit notes you can still use ActiveRecord::Relation#explain to generate explain queries, but if you want to have it automatically called you will have to implement that yourself. Looking over the removed code in this commit should help you get on the right path.

like image 71
Alex.Bullard Avatar answered Sep 29 '22 18:09

Alex.Bullard