简体   繁体   English

MySQL(Percona 5.7)使用InnoDB引擎的慢ALTER表...?

[英]MySQL (Percona 5.7) Slow ALTER table with InnoDB engine …?

I have a table that is in InnoDB engine, quite a simple one with 25000 rows. 我有一个InnoDB引擎中的表,这是一个非常简单的表,具有25000行。 When I do a simple ALTER, it runs for almost 10 minutes: 当我执行一个简单的ALTER时,它将运行近10分钟:

mysql> ALTER TABLE `quote_followups_istvan` 
       ADD `customer_ip2` VARCHAR(20) NOT NULL DEFAULT '' AFTER `comment`;

Query OK, 0 rows affected (10 min 52.82 sec) Records: 0 Duplicates: 0 Warnings: 0 查询正常,受影响的0行(10分钟52.82秒)记录:0重复:0警告:0

But when I change it's engine to MyISAM, I get this: 但是,当我将其引擎更改为MyISAM时,我得到了:

mysql> alter table quote_followups_istvan engine="MyISAM";

Query OK, 25053 rows affected (0.56 sec) Records: 25053 Duplicates: 0 Warnings: 0 查询正常,受影响的25053行(0.56秒)记录:25053重复项:0警告:0

mysql> ALTER TABLE `quote_followups_istvan` 
       ADD `customer_ip3` VARCHAR(20) NOT NULL DEFAULT '' AFTER `comment`;

Query OK, 25053 rows affected (0.37 sec) Records: 25053 Duplicates: 0 Warnings: 0 查询正常,受影响的25053行(0.37秒)记录:25053重复项:0警告:0

So 10minutes vs 0.37s.... 所以10分钟比0.37秒....

What amd I missing here? 我在这里想念什么?

Let me answer my own question. 让我回答我自己的问题。 Reading on, articles like this one 阅读,像这样的文章

optimize mySql for faster alter table add column 优化MySQL以更快地更改表添加列

and many more, actually say that this is the "issue" with InnoDb tables, and suggest some alternative approaches. 还有更多,实际上是说这是InnoDb表的“问题”,并提出了一些替代方法。

So I can only conclude that this is a normal behavior. 所以我只能得出结论,这是正常现象。

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

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