Friday, 15 February 2013

Best solution for doing database migration on mysql? -


I am currently facing a problem while migrating, especially adding new fields to the existing table, where millions There are records, completion of a very long period. So I wonder if there is a special trick way to migrate it fast?

Make it without locking table, what you can do, create a new table with the right column , Select on old table data, rename old table, rename new table, drop "old named table"

something like that;

  Create table 'table' such as 'table'; Add table_NU column to optional table ...; Add table_NU column to optional table ...; Add table_NU column to optional table ...; Insert from 'Table_New' to 'Table' from 'Table', from 'Table', select x, y, z, 'newcol', 'newcol2', 'newcol3'; Give table table 'new' in `table`; - Drop table `table_old` - except now, now it is known ...   

There can be an index about thinking about each other, turn it off and then they After incorporating, it is enabled, thus they do not have to recalculate all the time.

No comments:

Post a Comment