0

I need to add a column on a huge InnoDB table (200GB) which resides on MySQL 4.1.21 (SunOS).

CPU has 16GB RAM and 200GB of more disk space.

Is there any quick way of adding this rather than ALTER TABLE? Because, ALTER TABLE as far as I know would take some months to complete.

Any thoughts experts?

asked Nov 12, 2013 at 13:01
5
  • Create temporary table with new column, import all data in temp table and then drop old table? No other way as far as I know. Commented Nov 12, 2013 at 13:03
  • Matteo, the problem with this approach is the table keeps on getting new records and it could not go offline for much time. Commented Nov 12, 2013 at 13:04
  • If this is not feasible, and you do not want to ALTER TABLE, I really do not see how you could do this... Commented Nov 12, 2013 at 13:07
  • What about creating a new table with the PK of the old one and the new column, renaming the old table and creating a view with the name of the old table, that joins the 2 together? Commented Nov 12, 2013 at 14:31
  • That's what I had suggested but from the application point of view, it was a tedious process to stop accessing the database even momentarily. Anyways, dev team decided to rework the code and skip this ALTER. Commented Nov 19, 2013 at 10:03

2 Answers 2

1

You can use statement-based replication and add the column to a slave first. Any pending modifications will queue up on the slave, and apply once the alter has complete. When the slave is fully up to date with the new schema, you can effectively 'promote' it.

I am sure you are aware, but MySQL 4.1 is quite old. Triggers were not introduced until MySQL 5.0 (2005), so this limits your options to use tools like pt-online-schema-change.

answered May 14, 2014 at 22:15
0
answered Nov 12, 2013 at 22:33
1
  • Thanks, Mark. But the solution needed to be really quick and without substantial downtime. Moreover, it's 4.1 version of MySQL which they are planning to move to Oracle. So no migrations in near future :( Commented Nov 19, 2013 at 10:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.