I am in the process of breaking up a wordpress site with one database and 81,000+ tables into a multi-DB using a plugin by wpmudev.org. The main motivator is performance and I checked the tables itself and they are of type MyISAM.
I was thinking that while moving the tables into new databases I could also change the table type to InnoDB which should see a site performance improvement.
The script to migrate tables from the existing db to the new db uses the following syntax:
CREATE TABLE …. LIKE ….
INSERT INTO …. SELECT * FROM ….
I could not locate information if I could oveerride the engine in the CREATE TABLE command such as:
CREATE TABLE …. LIKE …. ENGINE=InnoDB
Also I am wondering if “INSERT INTO …. SELECT * FROM ….” is the most efficient way to insert the data… This is a php script so I don’t mind adding a little code to improve the performance which – at an earlier trial took 3 days to run on a 4-core 4GB RAM!
You can’t specify ENGINE parametr with
create table like...
syntax, but here are some alternatives:… will copy table structure and data, without keys and trigers
… will copy just structure, but no data (because
WHERE 0
will filter all out)… maybe, you would like to add
TEMPORARY
word, then DB would automatically remove the table when you close the connection… and this is an example on how to recreate the keys in new table (syntax of defining keys as the same as in simple CREATE TABLE syntax)
Yes, I’ve done just this (override the table type). Works fine.
For big transfers like this I’ve generally done some form of database dump,
a script to massage the data (e.g. change engine types), then a restore to the new database. The text based database dumps mostly use
COPY
which is faster thanINSERT INTO
.You can also issue
ALTER TABLE {} ENGINE=INNODB;
. Though that said a fresh start has a lot going for it also.81,000 tables. Wow.
This question was also answered indirectly by another question, which helped me as I was trying to clone a table into the MEMORY engine:
how-to-copy-mysql-table-structure-to-table-in-memory
Hope this helps someone as it helped me!
Or just: