Rails indexes is a small package of 2 rake tasks that scan your application models and displays a list of columns that probably should be indexed.
Note: there should be mode fields depending on your application design and custom queries.
Add rails_indexes to your Gemfile:
gem "rails_indexes", :git => "https://github.com/warpc/rails_indexes"
and install gem
Display a migration for adding/removing all necessary indexes based on associations:
Display a migration for adding/removing all necessary indexes based on AR::Base#find calls (including:
Notice: At now moment it does not support Arel(the new Rails 3 Active Record Query Interface) calls (including: where, joins, includes, from, select...), but still usefull for indexes based on association
Note that add index in big database may take a long time.
Compatible with Ruby 1.9 and Rails 3.
- Support Arel(the new Rails 3 Active Record Query Interface) call for
- Compatible with Ruby 1.9 and Rails 3
- Installing as Gem
- Working STI analize
- Good test coverage with RSpec
- Do not suggest add index for primary key (about reason read below)
The primary key is always indexed. This is generally true for all storage engines that at all supports indices.
For this reason, no longer displays a gem suggestions about adding indexes to primary keys.
bundle install rake
to run the tests.
All feedback, bug reports and thoughts on this gratefully received.
Elad Meidar - http://blog.eizesus.com
Thanks: Eric Davis - http://littlestreamsoftware.com
Released under the same license as Ruby. No Support. No Warranty, no Pain.