简体   繁体   English

Aurora DB 中的 Alter 命令(添加新列)

[英]Alter command in the Aurora DB (add a new Column)

There is a requirement to add a new column with a default value varchar(1) where the table has 75 million+ records.需要添加一个具有默认值 varchar(1) 的新列,其中表有 7500 万条以上的记录。 Performed the tests in perf environment, it ran fine with 40 mins, but there is no live traffic.在 perf 环境中执行测试,它运行良好 40 分钟,但没有实时流量。 Is there anyway we can expedite this?无论如何,我们可以加快这一进程吗? Can disabling the indexes on the table may help expedite the alter command?禁用表上的索引可以帮助加快 alter 命令吗?

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.我认为你最终不会节省任何时间。

But I would recommend learning to use pt-online-schema-change .但我建议学习使用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.这是一个在后台运行模式更改的工具,可以这么说,而您的应用程序可以继续读取和写入原始表。

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.假设需要两个小时而不是 40 分钟。 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.模式更改工具确实需要在工作开始和结束时短暂锁定表。

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

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