Which statement best describes the meaning of the value for the key_len column?

Consider the following:
Mysql> EXPLAIN SELECT * FROM City WHERE Name = ‘Jacksonville’ AND CountryCode =
‘USA’ \G
******************************** 1. row ********************************
Id: 1
Select_type: SIMPLE
Table: City
Type: ref
Possible_keys: name_country_index
Key: name_country_index
Ref: const, const
Rows: 1
Extra: Using where
Which statement best describes the meaning of the value for the key_len column?

Consider the following:
Mysql> EXPLAIN SELECT * FROM City WHERE Name = ‘Jacksonville’ AND CountryCode =
‘USA’ \G
******************************** 1. row ********************************
Id: 1
Select_type: SIMPLE
Table: City
Type: ref
Possible_keys: name_country_index
Key: name_country_index
Ref: const, const
Rows: 1
Extra: Using where
Which statement best describes the meaning of the value for the key_len column?

A.
It shows the total size of the index row.

B.
It shows how many columns in the index are examined.

C.
It shows the number of characters indexed in the key.

D.
It shows how many bytes will be used from each index row.

Explanation:



Leave a Reply 5

Your email address will not be published. Required fields are marked *


mutex

mutex

A: true. It’s the total index_row size. No matter how much it’s used.

CREATE TABLE a(
i int not null auto_increment primary key,
n varchar(10),
key n (n,i)
) default charset=utf8;

INSERT INTO a(n) values (‘c1’), (‘c2’), (‘c3′);

EXPLAIN SELECT * from a WHERE n=’c1’;

key_len=33

B: false, no columns 😉
c: false, an index is not measured in chars
D: false, it doesn’t depend on the used size