Skip to content

Instantly share code, notes, and snippets.

@wireframe
Created July 22, 2011 14:46
Show Gist options
  • Select an option

  • Save wireframe/1099601 to your computer and use it in GitHub Desktop.

Select an option

Save wireframe/1099601 to your computer and use it in GitHub Desktop.
module ActiveRecord::ConnectionAdapters::DatabaseStatements
def select_all_with_explain_plan(sql, name = nil)
missing_indexes = select_all_without_explain_plan("EXPLAIN #{sql}", "explain plan").reject {|r| r['key'] }
raise "Missing dataabase indexes: #{missing_indexes.inspect}" if missing_indexes.any?
select_all_without_explain_plan(sql, name)
end
alias_method_chain :select_all, :explain_plan
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment