Skip to content
WJunction - Webmaster Forum

Convert MyISAM tables to InnoDB

Status
Not open for further replies.
If you want to convert a MyISAM table to InnoDB, the process is fairly easy, but you can do something extra to speed things up. Before converting the table, adjust its order so that the primary key column is in order:

Code:
[COLOR=#990099][B]ALTER[/B][/COLOR] [COLOR=#990099][B]TABLE[/B][/COLOR] tablename [COLOR=#990099][B]ORDER BY[/B][/COLOR] [COLOR=#008000]'primary[COLOR=#008080][B]_[/B][/COLOR]key[COLOR=#008080][B]_[/B][/COLOR]column'[/COLOR][COLOR=#000033];[/COLOR]

This will pre-arrange the table so that it can be converted quickly without a lot of re-arranging required in MySQL. Then, simply change the table engine:

Code:
[COLOR=#990099][B]ALTER[/B][/COLOR] [COLOR=#990099][B]TABLE[/B][/COLOR] tablename [COLOR=#990099][B]ENGINE[/B][/COLOR] [COLOR=#CC0099]=[/COLOR] [COLOR=#990099][B]INNODB[/B][/COLOR][COLOR=#000033];[/COLOR]

If your table is large, then it may take a while to convert it over. There will probably be a fair amount of CPU usage and disk I/O in the process.
These statements are also safe in replicated environments. When you issue this statement to the master, it will begin the conversion process. Once it is complete on the master, the statement will roll down to the slaves, and they will begin the conversion as well. Keep in mind, however, that this can greatly reduce the performance of your configuration in the process.




I Havnt Written This Tutorial. Please Dont PM Me For Queries!
 

1 comment

Status
Not open for further replies.

About the author

I
Active Member · Joined
1,001
Messages
18
Reactions
38
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom