ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

Follow publication

Deep Understanding of MySQL Transactions.

Dwen
ITNEXT
Published in
7 min readSep 25, 2023

--

An In-Depth Explanation of MySQL Transaction Implementation and Principles.

Photo by Luca Bravo on Unsplash

In the process of using databases, transactions are a familiar concept.

A transaction’s primary goal is to ensure that a set of database operations either all succeed or all fail.

In MySQL, transaction support is implemented at the storage engine level.

It’s important to note that MySQL is a system that supports multiple storage engines, but not all of them provide transaction support. For instance, the native MySQL MyISAM storage engine does not support transactions, which is one of the significant reasons why InnoDB has replaced MyISAM.

In today’s blog, I will use InnoDB as an example to delve into MySQL’s specific implementation of transaction support and provide practical recommendations based on these principles.

I hope these case studies will deepen your understanding of MySQL’s transaction principles.

Isolation.

When we mention transactions, ACID(Atomicity, Consistency, Isolation, Durability)is certainly a term that comes to mind.

Today, we will delve into one of those aspects, which is Isolation or the I in ACID.

When multiple transactions are running concurrently on a database, it can lead to issues like dirty reads, non-repeatable reads, and phantom reads.

To resolve these problems, the concept of isolation levels was introduced.

It’s essential to understand that the stricter the isolation, the lower the efficiency.

Therefore, often we need to strike a balance between the two.

The SQL standard defines four transaction isolation levels:

  • Read Uncommitted: Before a transaction is committed, the changes it makes can be visible to other transactions.
  • Read Committed: After a transaction is committed, the changes it makes become visible to other transactions.
  • Repeatable Read: The data seen during the execution of a transaction remains consistent with the data the transaction initially saw when it started. In the Repeatable Read isolation level, uncommitted changes are also…

--

--

Published in ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

Written by Dwen

I'm an independent entrepreneur, a developer and a father, enjoys speaking, writing, and sharing.

No responses yet

Write a response