Mariadb 解释输出很奇怪

Mariadb explain output is strange

id:'1', 
select_type: 'SIMPLE', 
table: 's', 
type: 'index', 
possible_keys: 'PRIMARY',
key: 't_sensors_sensor_type_id_fk', 
key_len: '2', 
ref: NULL, 
rows: '4', 
Extra: 'Using index; Using temporary; Using filesort'

我的问题是: Possible keys column 是正确的,但是key column是错误的,mariadb选择了可能keys中没有出现的索引,为什么?

它不是 MariaDB 特定的,请参阅 MySQL 手册: http://dev.mysql.com/doc/refman/5.6/en/explain-output.html

It is possible that key will name an index that is not present in the possible_keys value. This can happen if none of the possible_keys indexes are suitable for looking up rows, but all the columns selected by the query are columns of some other index. That is, the named index covers the selected columns, so although it is not used to determine which rows to retrieve, an index scan is more efficient than a data row scan.