如何检查启用/禁用键是否有效?
我有一个带有索引 varchar(256)
列的表。
为了更快地进行批量插入,我禁用了键,插入超过 1000 万个条目,然后在插入完成后重新启用键。
令人惊讶的是,启用/禁用键不需要时间:
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)
如何确保启用/禁用键正常工作?
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 insertion 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要检查您的按键是否已启用/禁用,请运行:
如果该键被禁用,
Comment
列将显示disabled
。如果启用,该列将为空:To check if your keys are enabled/disabled, run:
If the key is disabled, the
Comment
column will showdisabled
. If it's enabled, the column will be empty:正如您所猜测的,InnoDB 不支持 DISABLE/ENABLE KEYS。您收到的警告是:
,正如您在此处看到的那样。
要亲自查看警告,请在运行
ALTER
后运行SHOW WARNINGS;
。As you guessed, InnoDB does not support DISABLE/ENABLE KEYS. The warning you got is:
As you can see here.
To see the warning yourself, run
SHOW WARNINGS;
after you run theALTER
.