Mar*_*c L 23

有一个rails_indexes的分支已经更新,可以与Rails 3和Ruby 1.9一起使用

https://github.com/plentz/lol_dba


Was*_*eem 16

您可以在控制台中粘贴以下代码以了解缺少的外键索引.但是,这并不像你所指的插件那样能够.它仅搜索具有_id列名末尾的rails样式外键.

c = ActiveRecord::Base.connection
c.tables.collect do |t|  
  columns = c.columns(t).collect(&:name).select {|x| x.ends_with?("_id") || x.ends_with?("_type")}
  indexed_columns = c.indexes(t).collect(&:columns).flatten.uniq
  unindexed = columns - indexed_columns
  unless unindexed.empty?
    puts "#{t}: #{unindexed.join(", ")}"
  end
end
Run Code Online (Sandbox Code Playgroud)

资源