sue445
2015/10/01 表参道.rb #5
https://gist.github.com/sue445/f890ea3fb5ef4fb5b9da
bundle exec rails r scripts/search_duplicate_indexes.rb
https://github.com/sue445/index_shotgun
group :development do
gem 'index_shotgun'
end
rake index_shotgun:fire
タスク名が 厨二病 カッコいい
# =============================
# user_stocks
# =============================
# index_user_stocks_on_user_id is a left-prefix of index_user_stocks_on_user_id_and_article_id
# To remove this duplicate index, execute:
ALTER TABLE `user_stocks` DROP INDEX `index_user_stocks_on_user_id`;
# =============================
# user_stocks
# =============================
# index_user_stocks_on_user_id_and_article_id_and_already_read has unnecessary column already_read (index_user_stocks_on_user_id_and_article_id is unique index!)
# To remove this duplicate index, execute:
ALTER TABLE `user_stocks` DROP INDEX `index_user_stocks_on_user_id_and_article_id_and_already_read`;
# =============================
# user_stocks
# =============================
# index_user_stocks_on_user_id is a left-prefix of index_user_stocks_on_user_id_and_article_id_and_already_read
# To remove this duplicate index, execute:
ALTER TABLE `user_stocks` DROP INDEX `index_user_stocks_on_user_id`;
# ########################################################################
# Summary of indexes
# ########################################################################
# Total Duplicate Indexes 3
# Total Indexes 6
# Total Tables 5
gem install
して
index_shotgun mysql --database=DATABASE
index_shotgun postgresql --database=DATABASE
index_shotgun sqlite3 --database=DATABASE
基本は前方一致
不要なindexはこまめにチェックしよう