{"id":21820581,"url":"https://github.com/sue445/index_shotgun","last_synced_at":"2025-04-05T09:07:52.414Z","repository":{"id":1229754,"uuid":"42007353","full_name":"sue445/index_shotgun","owner":"sue445","description":"duplicate index checker :fire: :gun: :cop:","archived":false,"fork":false,"pushed_at":"2025-01-17T23:51:40.000Z","size":272,"stargazers_count":38,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T08:08:11.398Z","etag":null,"topics":["activerecord","gem","index","mysql","oracle","postgresql","sqlite3"],"latest_commit_sha":null,"homepage":"https://sue445.github.io/index_shotgun/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sue445.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-06T15:22:01.000Z","updated_at":"2025-01-17T23:51:39.000Z","dependencies_parsed_at":"2024-06-29T17:41:01.441Z","dependency_job_id":"293ae293-78b3-400c-9240-bc8b36d3ce20","html_url":"https://github.com/sue445/index_shotgun","commit_stats":{"total_commits":282,"total_committers":4,"mean_commits":70.5,"dds":"0.12411347517730498","last_synced_commit":"c1c2dae3395bed02b78f411ca04263dd1faafbd6"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sue445%2Findex_shotgun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sue445%2Findex_shotgun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sue445%2Findex_shotgun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sue445%2Findex_shotgun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sue445","download_url":"https://codeload.github.com/sue445/index_shotgun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312078,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","gem","index","mysql","oracle","postgresql","sqlite3"],"created_at":"2024-11-27T16:37:47.295Z","updated_at":"2025-04-05T09:07:51.864Z","avatar_url":"https://github.com/sue445.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IndexShotgun :fire: :gun: :cop:\n[![Gem Version](https://badge.fury.io/rb/index_shotgun.svg)](http://badge.fury.io/rb/index_shotgun)\n[![test](https://github.com/sue445/index_shotgun/actions/workflows/test.yml/badge.svg)](https://github.com/sue445/index_shotgun/actions/workflows/test.yml)\n[![Code Climate](https://codeclimate.com/github/sue445/index_shotgun/badges/gpa.svg)](https://codeclimate.com/github/sue445/index_shotgun)\n\nDuplicate index checker.\n\nThis like [pt-duplicate-key-checker](https://www.percona.com/doc/percona-toolkit/2.1/pt-duplicate-key-checker.html), but also supports database other than MySQL\n\n## Example\n```sh\n$ index_shotgun postgresql --database=index_shotgun_test\n# =============================\n# user_stocks\n# =============================\n\n# index_user_stocks_on_user_id is a left-prefix of index_user_stocks_on_user_id_and_article_id\n# To remove this duplicate index, execute:\nALTER TABLE `user_stocks` DROP INDEX `index_user_stocks_on_user_id`;\n\n# =============================\n# user_stocks\n# =============================\n\n# index_user_stocks_on_user_id_and_article_id_and_already_read has column(s) on the right side of unique index (index_user_stocks_on_user_id_and_article_id). You can drop if low cardinality\n# To remove this duplicate index, execute:\nALTER TABLE `user_stocks` DROP INDEX `index_user_stocks_on_user_id_and_article_id_and_already_read`;\n\n# =============================\n# user_stocks\n# =============================\n\n# index_user_stocks_on_user_id is a left-prefix of index_user_stocks_on_user_id_and_article_id_and_already_read\n# To remove this duplicate index, execute:\nALTER TABLE `user_stocks` DROP INDEX `index_user_stocks_on_user_id`;\n\n# ########################################################################\n# Summary of indexes\n# ########################################################################\n\n# Total Duplicate Indexes  3\n# Total Indexes            6\n# Total Tables             5\n```\n\n## Requirements\n* Ruby 2.5+\n* Database you want to use (ex. MySQL, PostgreSQL or SQLite3)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngroup :development do\n  gem 'index_shotgun'\nend\n```\n\nAnd then execute:\n\n```sh\n# MySQL\n$ bundle install --without oracle postgresql sqlite3\n\n# Oracle\n$ bundle install --without mysql postgresql sqlite3\n\n# PostgreSQL\n$ bundle install --without mysql oracle sqlite3\n\n# sqlite3\n$ bundle install --without mysql oracle postgresql\n```\n\nOr install it yourself as:\n\n```sh\n$ gem install index_shotgun\n```\n\nIf you want to use as commandline tool, you need to install these gems.\n\n```sh\n# MySQL\n$ gem install mysql2\n\n# Oracle\n$ gem install activerecord-oracle_enhanced-adapter ruby-oci8\n\n# PostgreSQL\n$ gem install pg\n\n# sqlite3\n$ gem install sqlite3\n```\n\n**Note:** requirements `activerecord` gem v4.2.5+ when using `mysql2` gem v0.4.0+\n\n## Usage\n### Ruby app\n\n```sh\n$ bundle exec rake index_shotgun:fire\n```\n\nrun `fire` :fire: task\n\nIf you don't use Rails app, append this to `Rakefile`\n\n```ruby\nrequire \"index_shotgun/tasks\"\n```\n\n### Command line\nSupport these commands\n\n```sh\n$ index_shotgun\nCommands:\n  index_shotgun help [COMMAND]                  # Describe available commands or one specific command\n  index_shotgun mysql --database=DATABASE       # Search duplicate indexes on MySQL\n  index_shotgun oracle --database=DATABASE      # Search duplicate indexes on Oracle\n  index_shotgun postgresql --database=DATABASE  # Search duplicate indexes on PostgreSQL\n  index_shotgun sqlite3 --database=DATABASE     # Search duplicate indexes on sqlite3\n  index_shotgun version                         # Show index_shotgun version\n```\n\n**Details:** check `index_shotgun help \u003cdatabase\u003e`\n\n#### MySQL\n```sh\n$ index_shotgun help mysql\nUsage:\n  index_shotgun mysql d, --database=DATABASE\n\nOptions:\n  d, --database=DATABASE\n      [--encoding=ENCODING]\n                                             # Default: utf8\n      [--pool=N]\n                                             # Default: 5\n  h, [--host=HOST]\n                                             # Default: localhost\n  P, [--port=N]\n                                             # Default: 3306\n  u, [--username=USERNAME]\n  p, [--password=PASSWORD]\n      [--ask-password], [--no-ask-password]\n\nSearch duplicate indexes on MySQL\n```\n\n#### Oracle\n```sh\n$ index_shotgun help oracle\nUsage:\n  index_shotgun oracle d, --database=DATABASE\n\nOptions:\n  d, --database=DATABASE\n      [--encoding=ENCODING]\n                                             # Default: utf8\n      [--pool=N]\n                                             # Default: 5\n  h, [--host=HOST]\n                                             # Default: localhost\n  P, [--port=N]\n                                             # Default: 1521\n  u, [--username=USERNAME]\n  p, [--password=PASSWORD]\n      [--ask-password], [--no-ask-password]\n\nSearch duplicate indexes on Oracle\n```\n\n#### PostgreSQL\n```sh\n$ index_shotgun help postgresql\nUsage:\n  index_shotgun postgresql d, --database=DATABASE\n\nOptions:\n  d, --database=DATABASE\n      [--encoding=ENCODING]\n                                             # Default: utf8\n      [--pool=N]\n                                             # Default: 5\n  h, [--host=HOST]\n                                             # Default: localhost\n  P, [--port=N]\n                                             # Default: 5432\n  u, [--username=USERNAME]\n  p, [--password=PASSWORD]\n      [--ask-password], [--no-ask-password]\n\nSearch duplicate indexes on PostgreSQL\n```\n\n#### SQLite3\n```sh\n$ index_shotgun help sqlite3\nUsage:\n  index_shotgun sqlite3 d, --database=DATABASE\n\nOptions:\n  d, --database=DATABASE\n\nSearch duplicate indexes on sqlite3\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec index_shotgun` to use the gem in this directory, ignoring other installed copies of this gem.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/sue445/index_shotgun.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n## FAQ\n### Q. The origin of the name?\nA. **Index Shotgun** is one of SQL Antipatterns.\n\nhttps://pragprog.com/book/bksqla/sql-antipatterns\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsue445%2Findex_shotgun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsue445%2Findex_shotgun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsue445%2Findex_shotgun/lists"}