[英]How can I speed-up the table reconstruction in MySQL when altering the schema?
I have a relatively big MySQL InnoDB table (compressed), and I sometimes need to alter its schema (increasing column size or adding a field). 我有一个相对较大的MySQL InnoDB表(已压缩),有时我需要更改其架构(增加列大小或添加字段)。
It takes around 1 hour for a 500 MB table with millions of rows, but the server doesn't seem to be very busy (CPU @5%, not much RAM used, and 2.5 MB/s as I/O). 具有数百万行的500 MB表大约需要1个小时,但是服务器似乎并不很忙(CPU @ 5%,未使用太多RAM,并且I / O为2.5 MB / s)。
The table is not used in production so there are no concurrent requests at the same time. 该表未在生产中使用,因此没有同时存在的并发请求。 There is only a primary index (on the first 5 columns) and one foreign key constraint.
只有一个主索引(在前5列上)和一个外键约束。
Do you have any suggestion on how to speed-up the table alteration process? 您对如何加快表格更改过程有任何建议吗?
在InnoDB被“修复”之前,改变存储引擎(向TokuDB之类的新一代引擎)似乎是必须的。
Would be helpful to know the exact table and primary key/index definitions, and of lesser importance, the row count to the nearest million, although I would guess as the table is only 500mb it's probably less than 20 million rows. 了解确切的表和主键/索引定义会有所帮助,并且次要的是,将行数精确到最接近的百万,尽管我猜想因为表只有500mb,所以可能少于2000万行。 Also, your approach to changing the table - are you creating a new schema and inserting into it, or using a alter table etc.
另外,更改表的方法-是创建新的架构并将其插入其中,还是使用alter table等。
I've had success in this area before with approaches like 我曾经在这方面取得过成功,例如
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.