Get the App
SLTechnology News&Howtos  ›  Database  › 

The function of transaction Log in mysql Database

Shulou Source: shulou.com Published: 2022-06-01 14:58:53 11月20日 Update

This article will explain in detail the role of transaction logs in mysql database for everyone. The content of the article is of high quality, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.

MySQL transaction logs can help improve the efficiency of transactions. A transaction log is a file separate from the database file that stores all changes made to the database and records inserts, updates, deletes, commits, fallbacks, and database schema changes.

What is a transaction log?

To ensure the integrity of ACID transactions must rely on the transaction log for tracking, each operation is written to the log file before it is actually written to the database. If you want to delete a row of data, you will mark the row as deleted in the log file, but the data file in the database has not changed.

Only after the entire transaction (containing multiple sql statements) is committed, the sql statements in the entire transaction are batch synchronized to the database file on disk.

Every write operation on the transaction engine needs to be executed twice:

1. Write to the log file first

Writing log files is only the operation process, not the operation data itself, so the speed is much faster than writing database files.

2, and then write to the database file

Operations written to database files are records of committed transaction operations in the redo transaction log.

log group

Generally, more than one log file is set, and another log file is used to improve server efficiency after one file is full.

Log file space will be automatically released after synchronization to disk, a single log file should not be set too large, if the log file is too large, mysql process may crash when synchronizing logs to data files.

Purpose of transaction log

Transaction logging can help improve the efficiency of transactions.

The transaction log is a file separate from the database file. It stores all changes made to the database and records all inserts, updates, deletions, commits, fallbacks, and database schema changes. Transaction logs, also known as roll forward logs or redo logs, are an important component of backup and recovery and are necessary for replicating data using SQL Remote.

About mysql database transaction log role to share here, hope the above content can have some help to everyone, can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Tags: Logs files transactions data databases efficiency changes synchronization help functions content articles more schemas knowledge disks articles statements speed storage Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Technology Redmi vpn Apple