Considered key_len in the EXPLAIN command of MySQL?

Please tell me how is considered the key_len in the EXPLAIN MySQL?

The key_len column contains the key length, that I decided to use MySQL. If the key is NULL, then the length of the key, (key_len) is also NULL. Please note: the length value of key, you can determine how many parts of this composite key will actually use MySQL.


I have a table partners, it has a id field (primary key), datatype INT, length 11, execute the query:
EXPLAIN SELECT * FROM partners WHERE id = 1;

Get the following result:
id;select_type;table;type;possible_keys;key;key_len;ref;rows;Extra
1;SIMPLE;partners;const;PRIMARY;PRIMARY;4;const;1;

The value of key_len = 4, why? How is it calculated?

Thank you.
July 8th 19 at 16:40
1 answer
July 8th 19 at 16:42
Solution
Shown used key length in bytes.
INT - 4 bytes and is. And the length and int is always 4 bytes, the numbers in the brackets has no effect in terms of storage, used by some clients to align the table display only.
Thank you very much - Carolyne65 commented on July 8th 19 at 16:45

Find more questions by tags MySQL