Your ALTER TABLE statement assumes that mysql will have to rewrite each row of the table, including a new column. Since you have more than 2 million lines, I would definitely expect that it will take a considerable amount of time, during which your server will most likely be mainly connected with IO. Normally, it would be more convenient for you to do the following:
CREATE TABLE main_table_new LIKE main_table; ALTER TABLE main_table_new ADD COLUMN location varchar(256); INSERT INTO main_table_new (fields_in_main_table) SELECT * FROM main_table; RENAME TABLE main_table TO main_table_old, main_table_new TO main_table; DROP TABLE main_table_old;
Thus, you add a column to an empty table and basically write data to this new table, which, as you are sure, no one will look for without locking as many resources as possible.
Romain Sep 29 2018-11-11T00: 00Z
source share