All Projects â†’ sue445 â†’ index_shotgun

sue445 / index_shotgun

Licence: MIT license
duplicate index checker 🔥 🔫 👮

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to index shotgun

Openrecord
Make ORMs great again!
Stars: ✭ 474 (+1254.29%)
Mutual labels:  activerecord, oracle, sqlite3
rails cursor pagination
Add cursor pagination to your ActiveRecord backed application
Stars: ✭ 21 (-40%)
Mutual labels:  activerecord, gem
activerecord-shard for
Database Sharding Library for ActiveRecord
Stars: ✭ 16 (-54.29%)
Mutual labels:  activerecord, gem
Algoliasearch Rails
AlgoliaSearch integration to your favorite ORM
Stars: ✭ 352 (+905.71%)
Mutual labels:  activerecord, gem
Soci
Official repository of the SOCI - The C++ Database Access Library
Stars: ✭ 960 (+2642.86%)
Mutual labels:  oracle, sqlite3
Sqlcheck
Automatically identify anti-patterns in SQL queries
Stars: ✭ 2,062 (+5791.43%)
Mutual labels:  oracle, sqlite3
filtered
Filters ActiveRecord queries in a nice way
Stars: ✭ 28 (-20%)
Mutual labels:  activerecord, gem
json-sql-builder2
Level Up Your SQL-Queries
Stars: ✭ 59 (+68.57%)
Mutual labels:  oracle, sqlite3
Pwned
Simple C++ code for simple tasks
Stars: ✭ 16 (-54.29%)
Mutual labels:  activerecord, sqlite3
Datagrid
Gem to create tables grids with sortable columns and filters
Stars: ✭ 921 (+2531.43%)
Mutual labels:  activerecord, gem
Active reporting
OLAP-like DSL for ActiveRecord-based reporting
Stars: ✭ 83 (+137.14%)
Mutual labels:  activerecord, gem
Ezsql
PHP class to make interacting with a database ridiculusly easy
Stars: ✭ 804 (+2197.14%)
Mutual labels:  oracle, sqlite3
Mormot
Synopse mORMot ORM/SOA/MVC framework
Stars: ✭ 607 (+1634.29%)
Mutual labels:  oracle, sqlite3
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (+382.86%)
Mutual labels:  oracle, sqlite3
Entityframework.exceptions
Handle database errors easily when working with Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql
Stars: ✭ 266 (+660%)
Mutual labels:  oracle, sqlite3
rails-countries
Integration between Rails and countries gem.
Stars: ✭ 17 (-51.43%)
Mutual labels:  activerecord, gem
plant erd
ERD exporter with PlantUML and mermaid format
Stars: ✭ 126 (+260%)
Mutual labels:  oracle, sqlite3
Counter culture
Turbo-charged counter caches for your Rails app.
Stars: ✭ 1,397 (+3891.43%)
Mutual labels:  activerecord, gem
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (+185.71%)
Mutual labels:  activerecord, gem
active record-updated at
Touch `updated_at` by default with calls to `update_all` and `update_column(s)`
Stars: ✭ 27 (-22.86%)
Mutual labels:  activerecord, gem

IndexShotgun 🔥 🔫 👮

Gem Version Build Status Code Climate Coverage Status

Duplicate index checker.

This like pt-duplicate-key-checker, but also supports database other than MySQL

Example

$ index_shotgun postgresql --database=index_shotgun_test
# =============================
# 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 column(s) on the right side of unique index (index_user_stocks_on_user_id_and_article_id). You can drop if low cardinality
# 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

Requirements

  • Ruby 2.3+
  • Database you want to use (ex. MySQL, PostgreSQL or SQLite3)

Installation

Add this line to your application's Gemfile:

group :development do
  gem 'index_shotgun'
end

And then execute:

# MySQL
$ bundle install --without oracle postgresql sqlite3

# Oracle
$ bundle install --without mysql postgresql sqlite3

# PostgreSQL
$ bundle install --without mysql oracle sqlite3

# sqlite3
$ bundle install --without mysql oracle postgresql

Or install it yourself as:

$ gem install index_shotgun

If you want to use as commandline tool, you need to install these gems.

# MySQL
$ gem install mysql2

# Oracle
$ gem install activerecord-oracle_enhanced-adapter ruby-oci8

# PostgreSQL
$ gem install pg

# sqlite3
$ gem install sqlite3

Note: requirements activerecord gem v4.2.5+ when using mysql2 gem v0.4.0+

Usage

Ruby app

$ bundle exec rake index_shotgun:fire

run fire 🔥 task

If you don't use Rails app, append this to Rakefile

require "index_shotgun/tasks"

Command line

Support these commands

$ index_shotgun
Commands:
  index_shotgun help [COMMAND]                  # Describe available commands or one specific command
  index_shotgun mysql --database=DATABASE       # Search duplicate indexes on MySQL
  index_shotgun oracle --database=DATABASE      # Search duplicate indexes on Oracle
  index_shotgun postgresql --database=DATABASE  # Search duplicate indexes on PostgreSQL
  index_shotgun sqlite3 --database=DATABASE     # Search duplicate indexes on sqlite3
  index_shotgun version                         # Show index_shotgun version

Details: check index_shotgun help <database>

MySQL

$ index_shotgun help mysql
Usage:
  index_shotgun mysql d, --database=DATABASE

Options:
  d, --database=DATABASE
      [--encoding=ENCODING]
                                             # Default: utf8
      [--pool=N]
                                             # Default: 5
  h, [--host=HOST]
                                             # Default: localhost
  P, [--port=N]
                                             # Default: 3306
  u, [--username=USERNAME]
  p, [--password=PASSWORD]
      [--ask-password], [--no-ask-password]

Search duplicate indexes on MySQL

Oracle

$ index_shotgun help oracle
Usage:
  index_shotgun oracle d, --database=DATABASE

Options:
  d, --database=DATABASE
      [--encoding=ENCODING]
                                             # Default: utf8
      [--pool=N]
                                             # Default: 5
  h, [--host=HOST]
                                             # Default: localhost
  P, [--port=N]
                                             # Default: 1521
  u, [--username=USERNAME]
  p, [--password=PASSWORD]
      [--ask-password], [--no-ask-password]

Search duplicate indexes on Oracle

PostgreSQL

$ index_shotgun help postgresql
Usage:
  index_shotgun postgresql d, --database=DATABASE

Options:
  d, --database=DATABASE
      [--encoding=ENCODING]
                                             # Default: utf8
      [--pool=N]
                                             # Default: 5
  h, [--host=HOST]
                                             # Default: localhost
  P, [--port=N]
                                             # Default: 5432
  u, [--username=USERNAME]
  p, [--password=PASSWORD]
      [--ask-password], [--no-ask-password]

Search duplicate indexes on PostgreSQL

SQLite3

$ index_shotgun help sqlite3
Usage:
  index_shotgun sqlite3 d, --database=DATABASE

Options:
  d, --database=DATABASE

Search duplicate indexes on sqlite3

Development

After 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.

To 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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/index_shotgun.

License

The gem is available as open source under the terms of the MIT License.

FAQ

Q. The origin of the name?

A. Index Shotgun is one of SQL Antipatterns.

https://pragprog.com/book/bksqla/sql-antipatterns

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].