P
P
Pavlo Ponomarenko2010-12-18 18:14:03
MySQL
Pavlo Ponomarenko, 2010-12-18 18:14:03

mysql: slow alter?

Hi guys. There is a need for production in a table in which 1M records to insert one more field.
But alter in mysql copies the entire table , which is why such an operation is very long. Server - combat, simple - unacceptable. Maybe there is a possibility to add one more field to the table so as not to block the site? What do you suggest?
Debian 5, Mysql 5.1,
2gb ram, Intel® Atom(TM) CPU D510 @ 1.66GHz
+ replication server connected (slave)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pwlnw, 2010-12-18
@pwlnw

Since you have mastered normal replication, then deal with master-master replication as well. Alternately on each server make ALTER. While ALTER is running, send requests to another server.
>2gb ram, Intel® Atom(TM) CPU D510 @ 1.66GHz
>Server - combat, simple - unacceptable.
I don't really believe it, by the way.

A
Alexander Belugin, 2010-12-18
@unkinddragon

CREATE TABLE new_name (new Layout); 

INSERT INTO new_name 
SELECT (column_list) FROM old_name; 

RENAME TABLE old_name TO to_delete_name, new_name TO old_name;

The bottom line is that you can copy all the data into a new table. Minus - during this time it is better not to write new data, because. they may not make it into the copy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question