-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report low cardinality indices #31
Comments
mysql@localhost[index_digest]>SHOW INDEX FROM 0020_big_table;
+----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| 0020_big_table | 0 | PRIMARY | 1 | item_id | A | 100405 | NULL | NULL | | BTREE | | |
| 0020_big_table | 1 | text_idx | 1 | text | A | 100405 | NULL | NULL | | BTREE | | |
+----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
2 rows in set (0,00 sec)
--
mysql@localhost[index_digest]>select TABLE_NAME, INDEX_NAME, COLUMN_NAME, CARDINALITY from INFORMATION_SCHEMA.STATISTICS where TABLE_NAME = '0020_big_table' AND TABLE_SCHEMA = 'index_digest';
+----------------+------------+-------------+-------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+----------------+------------+-------------+-------------+
| 0020_big_table | PRIMARY | item_id | 100405 |
| 0020_big_table | text_idx | text | 100405 |
+----------------+------------+-------------+-------------+
2 rows in set (0,00 sec) |
mysql@localhost[index_digest]>select * from 0020_big_table limit 10;
+---------+-----+-------+-----+
| item_id | val | text | num |
+---------+-----+-------+-----+
| 1 | 1 | 00001 | 1 |
| 2 | 1 | 00002 | 2 |
| 3 | 1 | 00003 | 0 |
| 4 | 1 | 00004 | 1 |
| 5 | 1 | 00005 | 2 |
| 6 | 2 | 00006 | 0 |
| 7 | 2 | 00007 | 1 |
| 8 | 2 | 00008 | 2 |
| 9 | 2 | 00009 | 0 |
| 10 | 2 | 0000a | 1 |
+---------+-----+-------+-----+
10 rows in set (0,01 sec)
--
mysql@localhost[index_digest]>select TABLE_NAME, INDEX_NAME, COLUMN_NAME, CARDINALITY from INFORMATION_SCHEMA.STATISTICS where TABLE_NAME = '0020_big_table' AND TABLE_SCHEMA = 'index_digest';
+----------------+------------+-------------+-------------+
| TABLE_NAME | INDEX_NAME | COLUMN_NAME | CARDINALITY |
+----------------+------------+-------------+-------------+
| 0020_big_table | PRIMARY | item_id | 13 |
| 0020_big_table | text_idx | text | 13 |
| 0020_big_table | num_idx | num | 3 |
+----------------+------------+-------------+-------------+
3 rows in set (0,00 sec) After
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set the threshold of cardinality so that a single value covers at most 20% of table rows:
New report -
low_cardinality_index
The text was updated successfully, but these errors were encountered: