I simply discovered relating to this feature in innodb, and I am a little confused.
Besides doing multiple queries and rollback if one of these fails, what are the others?
And therefore are they reduced compared to normal queries?
Besides being able to do multiple queries and rollback if one of them fails, are there any others?
That's one of these. Most likely the primary benefit is you can make certain you won't ever leave the database within an sporadic condition, nor will another user being able to access the database simultaneously as you can see sporadic data. For instance, should you be managing a bank and also you needed clients to have the ability to transfer money into one another's accounts, you wouldn't want any snapshot from the data to possess any missing money, nor any excess money. Therefore if one customer transfers $100 to some friend, that will generally work like:
- $100 leaves the very first customer's account
- $100 comes to the friend's account
Without transactions, should you be searching in the two accounts just the incorrect time you may see each of them with no $100 and conclude your liabilities were $100 less, or something like that. With transactions, you can either begin to see the accounts as prior to the transaction or even the accounts as later on - no inconsistency.
And are they slower than the normal queries?
So far as I understand, transactions don't impose any significant performance penalty.
Using transactions can permit you to enforce Acidity qualities (atomicity, consistency, isolation, sturdiness): http://en.wikipedia.org/wiki/ACID
Transactions have two major reasons:
- Making certain atomicity of the complex operation -- that's, if a person step fails, the entire transaction is folded back, to ensure that the DB is not left within an sporadic condition.
- Making certain consistent condition. If you wish to make several read queries try not to want an intervening operation to alter the information within the DB, then just wrap the reads inside a transaction.