According to MySQL website, the key_len
column indicates the length of the key that MySQL decided to use. The length is NULL
if the key column says NULL
. Note that the value of key_len enables you to determine how many parts of a multiple-part key MySQL actually uses.
Using an example from my previous question, I have an EXPLAIN SELECT statement that shows MySQL using an Index
with key_len: 6
. Below shows the composition of the index and columns used.
`Type` char(1) NOT NULL,
`tn` char(1) NOT NULL DEFAULT 'l',
`act` tinyint(1) unsigned NOT NULL DEFAULT '0',
`flA` mediumint(6) unsigned NOT NULL DEFAULT '0',
KEY `Index` (`Type`, `tn`, `act`, `flA`)
So how does the value of key_len
allows me to determine that my query uses the first three parts of a multiple-part key?