Reputation: 6207
Logic says it should be really fast to add a NULL
column even if adding to a very large (~800 GB) table.
Obviously if the ALTER TABLE
has a NOT NULL
for the new column it will take a long time, but how about for NULL
columns? How does it compare to altering a small table?
I'm on MySql 5.5.
Thanks!
Upvotes: 3
Views: 2617
Reputation: 29769
MySQL implements ALTER TABLE
as a table recreation.
In most cases,
ALTER TABLE
makes a temporary copy of the original table (...) incorporates the alteration into the copy, deletes the original table, and renames the new one.
The manual goes on and explains what "most cases" means. Basically: adding, removing, and redefining columns.
Only the table size matters, the column type has little to no impact in terms of execution time.
Upvotes: 4