且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Aurora数据库中的Alter命令(添加新列)

更新时间:2023-11-30 15:30:58

禁用索引可能会有所帮助,但是当您再次启用索引时,必须重新构建它们,这也将花费很长时间.我认为您最后不会节省任何时间.

Disabling the indexes might help, but when you enable the indexes again, they'll have to be rebuilt, which will also take a long time. I don't think you'll save any time in the end.

但是我建议学习使用pt-online-schema-change .可以说,这是一个在后台运行模式更改的工具,而您的应用程序可以继续读取和写入原始表.

But I would recommend learning to use pt-online-schema-change. This is a tool that runs schema changes in the background, so to speak, while your application can continue to read and write the original table.

运行更改可能需要更长的时间.但是您不介意,因为没有停机时间.假设它需要两个小时而不是40分钟.没关系,因为应用程序不必等待架构更改完成.

It will probably take longer to run the alter. But you don't mind, because there is no downtime. Say it takes two hours instead of 40 minutes. It's okay because the application doesn't have to wait for the schema change to finish.

在我的工作中,我们每周在生产中运行数百个架构更改,而无需停机.模式更改工具确实需要在工作的开始和结束时短暂地锁定表.

At my job, we run hundreds of schema changes per week in production, without downtime. The schema change tool does need to lock the table briefly at the start and at the end of its work.