andrew / rails_indexes forked from eladmeidar/rails_indexes

A rake task to track down missing database indexes. does not assume that all foreign keys end with the convention of _id.

This URL has Read+Write access

name age message
file MIT-LICENSE Sat Sep 12 16:15:21 -0700 2009 Missing plugin files [eladmeidar]
file README.textile Tue Sep 15 17:27:15 -0700 2009 Again, README formatting.. HTML fail. [eladmeidar]
file Rakefile Sat Sep 12 16:15:21 -0700 2009 Missing plugin files [eladmeidar]
directory lib/ Tue Sep 29 08:19:04 -0700 2009 Ensure all indexes put into migration are unique. [andrew]
directory tasks/ Tue Sep 15 17:30:24 -0700 2009 Fixed the typo in the rake task on the deprecat... [eladmeidar]
directory test/ Sat Sep 12 16:15:21 -0700 2009 Missing plugin files [eladmeidar]
README.textile

Rails Indexes

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.

Installation

as a rails plugin:

script/plugin install git://github.com/eladmeidar/rails_indexes.git

Usage

Display a simple report:

rake db:show_me_some_indexes

deprecated

Display a migration for adding/removing all necessary indexes based on associations:

rake db:show_me_a_migration

Display a migration for adding/removing all necessary indexes based on AR::Base#find calls (including: find, find_by, find_all_by, find_by_x_and_y, find_all_by_x_and_y):

rake db:show_me_ar_find_indexes

Note that it would probably make more sense running those tasks on production, where you actually need those indexes to be added.

  • Add an option to create a migration that adds all the needed indexes.
  • Add an option to scan the application root tree for #find, #find_all_by and #find_by to get some more index-required columns.

Tests

There’s a test application.

Author:

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.