两列上的MySQL索引

时间:2013-08-03 10:09:27

标签: mysql indexing

我试图以这种方式在我的桌子上创建一个双列索引:

CREATE INDEX prod_hash_index ON components(producer_normalized, hash);

这导致不是一个,而是两个索引(当我SHOW INDEXES FROM components;时):

+------------+------------+-----------------+--------------+---------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table      | Non_unique | Key_name        | Seq_in_index | Column_name         | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+------------+------------+-----------------+--------------+---------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| components |          0 | PRIMARY         |            1 | id                  | A         |     1570231 |     NULL | NULL   |      | BTREE      |         |               |
| components |          1 | item_num        |            1 | item_num            | A         |     1570231 |     NULL | NULL   |      | BTREE      |         |               |
| components |          1 | fs_index        |            1 | first_symbol        | A         |         303 |     NULL | NULL   |      | BTREE      |         |               |
| components |          1 | prod_hash_index |            1 | producer_normalized | A         |          18 |     NULL | NULL   | YES  | BTREE      |         |               |
| components |          1 | prod_hash_index |            2 | hash                | A         |     1570231 |     NULL | NULL   |      | BTREE      |         |               |
+------------+------------+-----------------+--------------+---------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

这是什么意思? MySQL是否创建了额外的单列索引?

1 个答案:

答案 0 :(得分:0)

您在每行的结果面板中读取索引名称和索引列。

关于prod_has_index,第一行关于第一位的producer_normalized列 列中的另一行(seq_in_index)2。