Can I use InnoDB and MyISAM tables in ONE database?
Asked Answered
S

3

10

Obviously both have their benefits. MyISAM is fast but may get currupted easily, InnoDB is slow but is more stable thanks to transactions and foreign keys. So it could be good to mix both engines in one database. If that's possible?

Sudoriferous answered 28/12, 2009 at 16:26 Comment(0)
A
19

REMEMBER! It's OK to mix table types in the same database! In fact it's recommended and frequently required. However, it is important to note that if you are having performance issues when joining the two types, try converting one to the other and see if that fixes it. This issue does not happen often but it has been reported.

Taken from MySQL - InnoDB vs MyISAM

Adey answered 28/12, 2009 at 16:28 Comment(1)
its ok to mix table types just as you said,. but mixing table types within transactions should be avoided,.Vedetta
B
6

Sure, that's possible.

CREATE TABLE MyISAM_tbl(
    ....
)ENGINE=MyISAM;

CREATE TABLE InnoDB_tbl (
    ....
)ENGINE=InnoDB;

I do this all the time, because I prefer InnoDB for the FKs, but I sometimes need MyISAM for the full-text search. Never had a problem.

Bogtrotter answered 28/12, 2009 at 16:29 Comment(0)
L
1

In a word yes. (CREATE TABLE lets you specify the engine type.)

However, you have to take care when you're querying across multiple table types. (For example you can't take advantage of foreign keys on MyISAM and you can't commit a transaction that affects MyISAM tables, etc.)

In essence, I suspect this might not be the best approach to take. (Unless you only need transactions for a defined set of tables that are segmented from the remainder of your database and InnoDB is too slow, getting a faster database server may well transpire to be less painful.)

Lexine answered 28/12, 2009 at 16:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.