The Table
https://codex.wordpress.org/Database_Description
CREATE TABLE wp_terms (
term_id bigint(20) unsigned auto_increment,
name varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
slug varchar(200),
term_group bigint(10) DEFAULT 0,
PRIMARY KEY ( term_id )
) ENGINE=InnoDB;
The Index
MySQL> show index from wp_terms;
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| wp_terms | 1 | name | 1 | name | A | 716638 | 191 | NULL | | BTREE | | | YES | NULL |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
The Query
MySQL> select name from wp_terms order by name limit 1;
+--------------------+
| name |
+--------------------+
| **************** |
+--------------------+
1 row in set (0.83 sec)
The Explain
MySQL> explain select name from wp_terms order by name limit 1;
+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+----------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+----------------+
| 1 | SIMPLE | wp_terms | NULL | ALL | NULL | NULL | NULL | NULL | 802726 | 100.00 | Using filesort |
+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+----------------+
The Question
Why isn't the 'name' index even a possible key? Forcing it had no effect.
Thank you in advance.
wp_terms.name? (includingNULL/NOT NULL)wp_termstable?name, with high cardinality should mean the index is being used.sub_partis191(and notNULL), which means the column is only partially indexed, could that be why?