How to check if enable/disable keys work?

后端 未结 2 697
清酒与你
清酒与你 2021-01-01 04:54

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

相关标签:
2条回答
  • 2021-01-01 05:35

    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 讨论(0)
  • 2021-01-01 05:42

    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. ➫➫➫

    0 讨论(0)
提交回复
热议问题