简体   繁体   English

在MySQL 5.6“Alter Table Add Columns”中不允许DML并发

[英]In MySQL 5.6 “Alter Table Add Columns” not allowing DML concurrency

MySQL 5.6 claims that DDL operations will be run with the maximum possible concurrency. MySQL 5.6声称DDL操作将以最大可能的并发性运行。 http://dev.mysql.com/doc/refman/5.6/en/innodb-create-index-overview.html http://dev.mysql.com/doc/refman/5.6/en/innodb-create-index-overview.html

The “Allows Concurrent DML?” column shows which operations can be performed fully online; “允许并发DML?”列显示可以完全在线执行哪些操作; the preferred value is “Yes”. 首选值为“是”。 You can specify LOCK=NONE to assert that full concurrency is allowed during the DDL, but MySQL automatically allows this level of concurrency when possible. 您可以指定LOCK = NONE以断言在DDL期间允许完全并发,但MySQL会尽可能自动允许此级别的并发。 When concurrent DML is allowed, concurrent queries are also always allowed. 当允许并发DML时,也始终允许并发查询。

However I just tried an "ALTER TABLE ADD COLUMN... " statement and the table appeared locked during this operation. 但是我只是尝试了一个“ALTER TABLE ADD COLUMN ...”语句,并且该表在此操作期间显示为已锁定。 When I reran the statement and appended ",ALGORITHM=inplace, LOCK=none" then it took longer, but the table remained available to be used. 当我重新声明并附加“,ALGORITHM = inplace,LOCK = none”时,它需要更长的时间,但表仍然可以使用。 I thought MySQL would use the highest level of concurrency available for a particular statement so why did I have to specify them explicitly? 我认为MySQL会使用可用于特定语句的最高级别的并发性,那么为什么我必须明确指定它们呢?

The fact that Online DDL allows concurrent DML does not necessarily mean that it takes every opportunity to do so by default. Online DDL 允许并发DML的事实并不一定意味着默认情况下它会抓住每个机会。

The language about "allows this level of concurrency when possible" is a little bit hard to interpret. 关于“在可能的情况下允许这种并发性”的语言有点难以解释。 You may assume that MySQL always uses the inplace algorithm when it is possible, but think of it in the reverse: it really means that it does not allow the inplace algorithm when it is not possible. 您可以假设MySQL 总是在可能的情况下使用inplace算法,但反过来考虑它:它实际上意味着它在不可能时不允许使用inplace算法。 If inplace DDL is possible, it allows it, but does not actually use that algorithm unless you request it. 如果可以使用inplace DDL,它允许它,但实际上并不使用该算法,除非您请求它。

You observed yourself that Online DDL is slower. 您发现自己在线DDL速度较慢。 Is it not a reasonable default to use the faster method (since most people want things to be faster)? 使用更快的方法不是一个合理的默认值(因为大多数人希望事情更快)? After all, the table may be small enough that a non-inplace ALTER will take less than 1 second, and so it's not much of an interruption. 毕竟,该表可能足够小,非就地ALTER将花费不到1秒,因此它不会中断。 Enabling inplace ALTER in all cases where it is possible would make them take longer by default . 在可能的所有情况下启用inplace ALTER会使它们在默认情况下花费更长时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM