PDA

View Full Version : MySQL Engine Mixing


kjkoster
09-08-2008, 21:04
Dear All,

Not many people know that MySQL has several database storage engines (http://dev.mysql.com/doc/refman/5.1/en/storage-engines.html) to choose from. Even fewer people know that you choose these on a per-table basis. You can actually mix tables using different engines (http://dev.mysql.com/doc/refman/5.1/en/storage-engine-setting.html) in the same database.

For example, this forum keeps the login sessions in a memory table (http://dev.mysql.com/doc/refman/5.1/en/memory-storage-engine.html), while most other tables use the MyISAM engine. This means that restarting the server would clear the table and effectively logs all of you out. Luckily, your posts are retained (and I don't restart all that often).

Picking the right table is not as simple as a straightforward performance comparison. The InnoDB engine is considered to be one of the faster engines of MySQL when it comes to highly concurrent transaction processing. However, it never actually releases space it claims (http://bugs.mysql.com/bug.php?id=1287), causing active InnoDB tables to eat up all available disk space. This in turn forces database administrators to manually rebuild these tables to reclaim the wasted disk space.

This is just an example to show that it's not straightforward to pick the right table by looking at someone else's benchmarks.

Are there any issues that you are aware of when mixing table types?

What is your favourite MySQL table engine, and in what situation?

Kees Jan

PS. Perhaps I should introduce a MySQL blackhole table for the spammers. :p

Barry
13-08-2008, 12:07
The blackhole table does exist http://dev.mysql.com/doc/refman/5.1/en/blackhole-storage-engine.html

I'm not aware of any problems with mixing different engines, just be sure to document them properly so that the users of the tables understand the behaviour of the table.
So InnoDB does not reclaim space? Maybe they should implement something like PostgreSQL Vacuum.

kjkoster
14-08-2008, 08:34
Yes, I was aware the blackhole table type exists. :-)

From what I understand from the documentation and the bug resport I posted, innodb does not reclaim some of its space. My observations on my Zabbix server, which uses innodb, is that the tables files never shrink. I'm not sure if things like adding and deleting large strings in the database would make the problem worse or not.

For me, it is a reason not to use innodb for my Zabbix any longer. Disk space is an issue on that machine. Plus, I don't want to have to periodically rebuild the tables.

Kees Jan

Barry
14-08-2008, 08:38
Fortunately, Falcon (http://dev.mysql.com/tech-resources/articles/falcon-transactional-engine-part1.html) comes to the rescue.

kjkoster
16-08-2008, 22:23
Dear Barry,

Falcon certainly sounds great, especially the self-maintenance part. Do you have experience with this storage engine?

Kees Jan

Barry
23-08-2008, 11:59
No, unfortunately not; I just read the Sun marketing speak on it :)
I'm more a fan of Apache Derby as it is coded in Java and lets me understand the internals