Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MyIsam engine transaction support

Tags:

I was testing transaction support in innoDB tables, and just for the curriosity I tried to run the same transaction on MyIsam table, and surprisingly it worked. I am assuming that on myIsam table queries are executed one after another not in one atomic operation and I don't get any errors from START TRANSACTION and COMMIT and ROLLBACK operations. I am interested, is MyIsam engine just ignoring this operations or does it perform some actions?

like image 225
Headshota Avatar asked Nov 07 '11 11:11

Headshota


People also ask

What is engine MyISAM?

MyISAM stands for Indexed Sequential Access Method. It was the default storage engine for MySQL until December 2009. With the release of MySQL 5.5, MyISAM was replaced with InnoDB. MyISAM is based on an ISAM algorithm that displays information from large data sets fast.

Does MyISAM support foreign keys?

However, the older MyISAM storage engine does not include support for foreign keys. This means that MyISAM tables that are reverse engineered will not automatically have the relationship lines drawn between tables, making the database harder to understand.

Which is faster InnoDB or MyISAM?

In terms of data queries (SELECT), InnoDB is the clear winner, but when it comes to database writes (INSERT and UPDATE), MyISAM is somewhat faster. However, the lower speed of InnoDB is more than compensated for by its transaction protocol.

Which table types support MyISAM?

Note that MySQL supports two different kinds of tables: transaction-safe tables (InnoDB and BDB) and non-transaction-safe tables (HEAP, ISAM, MERGE, and MyISAM).


2 Answers

MyISAM effectively works in auto-commit mode (as it's not a transactional engine), and it just ignores the commit/rollback.

Actually storage engine is a different layer in the MySQL architecture, separated from the SQL parser, the SQL layer communicates to the storage engine with lower-level API, and that's the reason there is a common SQL and engines, supporting different subset of featured. You can see very high-level overview of the architecture here

like image 136
Maxim Krizhanovsky Avatar answered Oct 11 '22 14:10

Maxim Krizhanovsky


MyIsam tabels were not built for this. Not even in the 5+ versions. It only was meant to store data. It gives you no guarantee for transactions or data recovery. You should use InnoDB for this and, if needed, use MyIsam for replication purposes (it's faster to retrieve data with MyIsam tables since there's no cross-table checks).

You may read this post from MySQL http://forums.mysql.com/read.php?21,68686,69229#msg-69229

like image 38
Mário Rodrigues Avatar answered Oct 11 '22 12:10

Mário Rodrigues