WHERE TABLE_SCHEMA !='mysql'GROUP BY TABLE_SCHEMA, TABLE_NAME, INDEX_NAME )AS s2 ON s.TABLE_SCHEMA = s2.TABLE_SCHEMA AND s.TABLE_NAME = s2.TABLE_NAME AND s.INDEX_NAME = s2.INDEX_NAME
WHERE t.TABLE_SCHEMA !='mysql'/* Filter out the mysql system DB */
AND t.TABLE_ROWS >10/* Only tables with some rows */
AND s.CARDINALITY IS NOTNULL/* Need at least one non-NULL value in the field */
AND(s.CARDINALITY /IFNULL(t.TABLE_ROWS,0.01))<1.00/* unique indexes are perfect anyway */
ORDER BY`sel %`, s.TABLE_SCHEMA, s.TABLE_NAME /* DESC for best non-unique indexes */