Home  >  Article  >  Database  >  What is the use of mysql transaction log?

What is the use of mysql transaction log?

王林
王林Original
2020-06-28 10:53:183436browse

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

What is the use of mysql transaction log?

What is a transaction log

(Recommended tutorial: mysql tutorial)

To ensure the integrity of ACID, transactions must rely on transaction logs for tracking. Each operation is written to the log file before it is actually written to the database. If a row of data is to be deleted, the row will be marked in the log file as Delete, but the data files in the database have not changed.

Only after the entire transaction (including multiple sql statements) is submitted, the sql statements in the entire transaction are synchronized to the database file on the disk in batches.

Each write operation on the transaction engine needs to be performed twice:

1. Write to the log file first

The only operations written to the log file are process, rather than operating the data itself, so the speed is much faster than writing database files.

2. Then write it into the database file

The operation of writing the database file is to redo the records of the committed transaction operations in the transaction log.

Log group

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

The space of the log file will be automatically released after the log is synchronized to the disk. A single log file should not be set too large. If the log file is too large, the mysql process may crash when synchronizing the log to the data file.

Purpose of transaction log

Transaction log 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 fully records inserts, updates, deletes, commits, rollbacks, and database schema changes. Transaction logs are also called rollforward logs or redo logs. Transaction logs are an important component of backup and recovery, and are required to replicate data using SQL Remote.

The above is the detailed content of What is the use of mysql transaction log?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn