sql - MySQL Transaction/Commit Query -


just quick question need ask, mysql table using myisam storage engine , looking @ previous questions queries under engine automatically committed (no transactions allowed auto-commit).

now, mean, if following query:

update `exampletable` set `examplefield` += '50' ...;  update `exampletable2` set `examplefield2` -= '50' ...; 

it either succeed (and autocommit/update both) or fail , update neither?

or definition of query incorrect , myisam autocommit 1 command @ once? -so cannot above query reliably under myisam?

(bonus question) if so, have heard of innodb engine supports transactions. use instead? how speed losing in return reliable queries?

thanks help.

basically i'm asking: code above 1 query myisam autocommit, or sql treated 2 queries?

in myisam, code show treated 2 queries. concurrent client see data changed in progress. if want transaction isolation no concurrent thread can see data until commit, need use innodb.

i recommend innodb default choice on myisam. innodb has been default storage engine since mysql 5.5 (circa 2010).

there few cases myisam still wins, fewer , fewer. innodb when tuned performs better myisam. this blog 2007 shows benchmark results innodb on par with, or faster than, myisam under workloads. innodb has continued improved since then, while myisam has been stagnant , is gradually being phased out.

performance important, me, not corrupting data more important. myisam susceptible losing data in crash. innodb has automatic crash recovery. myisam fails support atomic changes. example, if run update takes 5 seconds, , 2.5 seconds kill query, half of rows have been changed , rest have not. innodb, never happen.

p.s. operators += , -= not supported in mysql (neither supported in other sql database know of). strictly speaking, neither of queries show anyway, except return error.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -