简体   繁体   中英

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. When I do a simple ALTER, it runs for almost 10 minutes:

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

But when I change it's engine to MyISAM, I get this:

mysql> alter table quote_followups_istvan engine="MyISAM";

Query OK, 25053 rows affected (0.56 sec) Records: 25053 Duplicates: 0 Warnings: 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

So 10minutes vs 0.37s....

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

and many more, actually say that this is the "issue" with InnoDb tables, and suggest some alternative approaches.

So I can only conclude that this is a normal behavior.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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