MyIsam engine transaction support
Asked Answered
R

2

31

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?

Rounds answered 7/11, 2011 at 11:44 Comment(3)
"worked" means that you were able to rollback a DML statement or that you didn't get syntax errors?Cordage
I did a simple select and insert statements and didn't received any errors.Rounds
Well, then see @Darhazer's answer. You might get no errors but you won't actually have transactions. Your INSERT won't be undone when you issue ROLLBACK.Cordage
C
38

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

Caoutchouc answered 7/11, 2011 at 11:48 Comment(0)
S
4

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

Spectroheliograph answered 7/11, 2011 at 11:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.