0

我试图以这种方式在我的表上创建一个两列索引:

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 是否创建了一个额外的单列索引?

4

1 回答 1

0

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

关于您拥有的 prod_has_index,关于 producer_normalized 列的第一行在位置 1 中,另一行在位置 (seq_in_index) 2 中具有列。

于 2013-08-03T10:12:52.520 回答