我的编程空间,编程开发者的网络收藏夹
学习永远不晚

Limitations of Online DDL for MySQL

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

Limitations of Online DDL for MySQL

Take the following limitations into account when running online DDL operations:

  • During an online DDL operation that copies the table, files are written to the temporary directory ($TMPDIR on Unix, %TEMP% on Windows, or the directory specified by the --tmpdir configuration variable). Each temporary file is large enough to hold one column in the new table or index, and each one is removed as soon as it is merged into the final table or index.

  • The table is copied, rather than using Fast Index Creation when you create an index on a TEMPORARY TABLE. This has been reported as MySQL Bug #39833.

  • InnoDB handles error cases when users attempt to drop indexes needed for foreign keys. See Section 14.18.5, “InnoDB Error Codes” for information related to error 1553.

  • The ALTER TABLE clause LOCK=NONE is not allowed if there are ON...CASCADE or ON...SET NULL constraints on the table.

  • During each online DDL ALTER TABLE statement, regardless of the LOCK clause, there are brief periods at the beginning and end requiring anexclusive lock on the table (the same kind of lock specified by the LOCK=EXCLUSIVE clause). Thus, an online DDL operation might wait before starting if there is a long-running transaction performing inserts, updates, deletes, or SELECT ... FOR UPDATE on that table; and an online DDL operation might wait before finishing if a similar long-running transaction was started while the ALTER TABLE was in progress.

  • When running an online ALTER TABLE operation, the thread that runs the ALTER TABLE operation will apply an “online log” of DML operations that were run concurrently on the same table from other connection threads. When the DML operations are applied, it is possible to encounter a duplicate key entry error (ERROR 1062 (23000): Duplicate entry), even if the duplicate entry is only temporary and would be reverted by a later entry in the “online log”. This is similar to the idea of a foreign key constraint check in InnoDB in which constraints must hold during a transaction.

  • OPTIMIZE TABLE for an InnoDB table is mapped to an ALTER TABLE operation to rebuild the table and update index statistics and free unused space in the clustered index. Prior to 5.6.17, there is no online DDL support for this operation. Secondary indexes are not created as efficiently because keys are inserted in the order they appeared in the primary key. As of 5.6.17, OPTIMIZE TABLE is supported with the addition of online DDL support for rebuilding regular and partitioned InnoDB tables. For additional information, see Section 14.10.1, “Overview of Online DDL”.

  • InnoDB tables created before MySQL 5.6 do not support ALTER TABLE ... ALGORITHM=INPLACE for tables that include temporal columns (DATE, DATETIME or TIMESTAMP) and have not been rebuilt using ALTER TABLE ... ALGORITHM=COPY. In this case, an ALTER TABLE ... ALGORITHM=INPLACE operation returns the following error:

    ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported. 
    Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.
    
  • These limitations are generally applicable to online DDL operations on large tables where table copying is involved:

    • There is no mechanism to pause an online DDL operation or to throttle I/O or CPU usage for an online DDL operation.

    • Progress monitoring capability for online DDL operations is limited until MySQL 5.7.6, which introduces Performance Schema stage events for monitoring ALTER TABLE progress. See Monitoring ALTER TABLE Progress for InnoDB Tables Using Performance Schema.

    • Rollback of an online DDL operation can be expensive should the operation fail.

    • Long running online DDL operations can cause replication lag. An online DDL operation must finish running on the master before it is run on the slave. Also, DML that was processed concurrently on the master is only processed on the slave after the DDL operation on the slave is completed (Bug #73196).

    • An online ALTER TABLE operation can cause a server exit if the operation uses all of the available disk space on the file system where the data directory (datadir) resides (Bug #77497). To avoid this problem, ensure that there is enough disk space to accommodate operations that copy the table. During these operations, MySQL writes temporary sort files to the temporary directory (--tmpdir).

    免责声明:

    ① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

    ② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

Limitations of Online DDL for MySQL

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

mysql之 openark-kit online ddl

MySQL工具集openark-kit (官方网站 http://code.openark.org/forge/openark-kit),内部包含很多小工具,在5.6之前用于实现online ddl操作,本文以CentOS为操作系统,且默认
2023-06-06

MySQL Online DDL原理解析

目录一、背景与意义二、工作机制1. 准备阶段2. 执行DDL操作3. 完成与清理三、实现原理与优化四、使用场景与优势五、使用约束与注意事项六、锁在Online DDL中的作用注意事项一、背景与意义在传统的数据库系统中,执行DDL操作时通常
MySQL Online DDL原理解析
2024-10-10

Mysql Online DDL的使用详解

目录正文LOCK参数ALGORITHM参数COPY TABLE流程IN-PLACE流程允许并发DML的DDL操作不允许并发DML的DDL操作正文Online DDL在MySQL 5.6才开始支持的,在5.5及之前版本,使用alter tab
2022-05-22

如何在Mysql中使用Online DDL

本篇文章为大家展示了如何在Mysql中使用Online DDL,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。LOCK参数LOCK=NONE:允许并发的查询和DML操作LOCK=SHARED:允许并发
2023-06-15

MySql Online DDL操作记录详解

目录一、环境二、执行过程分析三、遇到的问题四、工具尝试五、Online DDL 尝试一、环境为支持用户账号删除功能,需要在 user 表上加一个字段 deleted。数据库:mysql5.6被 操作表 user:数量级为100w,外键2
2022-12-20

MySql Online DDL操作问题怎么解决

本文小编为大家详细介绍“MySql Online DDL操作问题怎么解决”,内容详细,步骤清晰,细节处理妥当,希望这篇“MySql Online DDL操作问题怎么解决”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧
2023-07-04

MySQL Online DDL与DML并发阻塞关系总结

MySQL DDL操作执行的三种方式1,INPLACE,在进行DDL操作时,不影响表的读&写,可以正常执行表上的DML操作,避免与COPY方法相关的磁盘I/O和CPU周期,从而最小化数据库的总体负载。最小化负载有助于在DDL操作期间保持良好的性能和高吞吐量。2
MySQL Online DDL与DML并发阻塞关系总结
2017-11-12

MySQL 8.0 Online DDL快速加列的相关总结

目录问题描述MySQL Online DDL加列的历史方法01 Copy方法02 Inplace方法MySQL8.0.12 引入的Instant方法问题描述 前几天同事问了我一个问题:业务A从MySQL迁移到MongoDB的原因是什么? 说
2022-05-25

编程热搜

目录