Mysql: slow alter?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
31 views
Hi guys. There is a need for production to the table, which is 1M records insert another field.

But alter in mysql copies the entire table, which such operation is very lengthy. Server — the combat, the simple is not. Maybe there is the possibility to add another field to the table so as not to block the site? What you tell?


Debian 5, Mysql 5.1,

2gb ram, Intel® Atom(TM) CPU D510 @ 1.66 GHz

+ server is connected replication ( slave )
by | 31 views

2 Answers

0 like 0 dislike
Once you have mastered the normal replication figure it out and then with replication master-master. Alternately on each server do ALTER. During operation ALTER direct the requests to another server.
\r
>2gb ram, Intel® Atom(TM) CPU D510 @ 1.66 GHz
>Server — martial, the simple is not.
\r
Not particularly hard to believe, by the way.
by
0 like 0 dislike
CREATE TABLE new_name (new Layout); INSERT INTO new_name SELECT (column_list) FROM old_name; RENAME TABLE old_name TO to_delete_name, old_name TO new_name;

The point is that you can copy all the data into a new table. Negative – during that time it is better not to write new data, because they can not get a copy.
by

Related questions

0 like 0 dislike
1 answer
asked May 22, 2019 by Richard_Ferlow
0 like 0 dislike
2 answers
0 like 0 dislike
4 answers
0 like 0 dislike
2 answers
asked May 21, 2019 by litvinov-an
0 like 0 dislike
2 answers
asked Apr 9, 2019 by DrDragoN
110,608 questions
257,186 answers
0 comments
27,905 users