I have ran into some problems with MySQL that causes our index cardinality to show up as "NULL". I have noticed that for an index with multiple columns, only the Last column has an actual cardinality value. I have written this query but I want to confirm that there is nothing that I am missing:
SELECT s.TABLE_SCHEMA,
s.TABLE_NAME, s.INDEX_NAME,
s.cardinality,
MAX( s.SEQ_IN_INDEX ) AS MAX,
s.SEQ_IN_INDEX
FROM STATISTICS AS s,TABLES AS t
WHERE t.DATA_LENGTH >0
AND t.TABLE_SCHEMA = s.TABLE_SCHEMA
AND t.TABLE_NAME = s.TABLE_NAME
GROUP BY s.TABLE_SCHEMA, s.TABLE_NAME, s.INDEX_NAME
HAVING s.SEQ_IN_INDEX = MAX AND s.CARDINALITY IS NULL
I appreciate anyhelp.