Skip to content

Instantly share code, notes, and snippets.

@sorohan
Created July 15, 2014 07:03
Show Gist options
  • Save sorohan/aa920335304f53f2987c to your computer and use it in GitHub Desktop.
Save sorohan/aa920335304f53f2987c to your computer and use it in GitHub Desktop.

Revisions

  1. sorohan created this gist Jul 15, 2014.
    18 changes: 18 additions & 0 deletions check-mysql-disabled-keys.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash

    #
    # Check all databases/tables in mysql for disabled keys.
    #

    MYSQL="mysql"

    dbs=$(echo "show databases" | $MYSQL -N)
    for db in $dbs; do
    tables=$(echo "show tables" | $MYSQL -N $db)
    for tb in $tables; do
    indexes=$(echo "show indexes from $db.$tb" | mysql -N | grep disabled | awk '{print $3}')
    for i in $indexes; do
    echo "disabled index: $db.$tb.$i"
    done
    done
    done