开发者

How to check if enable/disable keys work?

开发者 https://www.devze.com 2023-02-09 23:34 出处:网络
I have a table with an indexed varchar(256) column. For faster bulk insert, I disabled keys, insert more than 10 million entries, and then re-enable the keys after insertio开发者_如何转开发n is done.

I have a table with an indexed varchar(256) column.

For faster bulk insert, I disabled keys, insert more than 10 million entries, and then re-enable the keys after insertio开发者_如何转开发n is done.

Surprisingly, the enable/disable keys took no time:

mysql> alter table xxx disable keys;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> alter table xxx enable keys;
Query OK, 0 rows affected, 1 warning (0.00 sec)

How do I ensure that enable/disable keys were working properly?


To check if your keys are enabled/disabled, run:

show keys in table_name
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+----------+---------------+
| Table    | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment  | Index_comment |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+----------+---------------+
| table123 |          0 | PRIMARY  |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |          |               |
| table123 |          1 | id       |            1 | id          | A         |        NULL |     NULL | NULL   |      | BTREE      | disabled |               |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+----------+---------------+

If the key is disabled, the Comment column will show disabled. If it's enabled, the column will be empty:

[Comment column shows] information about the index not described in its own column, such as disabled if the index is disabled. ➫➫➫


As you guessed, InnoDB does not support DISABLE/ENABLE KEYS. The warning you got is:

code 1031 - Table storage engine for 'table_name' doesn't have this option

As you can see here. To see the warning yourself, run SHOW WARNINGS; after you run the ALTER.

0

精彩评论

暂无评论...
验证码 换一张
取 消