Get the App
SLTechnology News&Howtos  ›  Database  › 

MYSQL behavior

Shulou Source: shulou.com Published: 2022-06-01 22:04:35 09月25日 Update

MySQL behavior

In MySQL, there are two variables that control behavior: the AUTOCOMMIT variable and the TRANSACTION ISOLACTION LEVEL variable.

Automatic submission

In MySQL, if you do not change its autocommit variable, the system will automatically submit the results to the database. During the database operation, users do not need to use START TRANSACTION statements to start transactions, apply COMMIT or ROLLBACK to commit transactions or perform rollback operations.

The isolated level of the transaction

Transactions have independent space. In MySQL servers, users execute different transactions through different sessions. In a multi-user environment, many RDBMS sessions are active at any given time. In order to make these transactions do not affect each other and ensure that the performance of the database is not affected, it is necessary to adopt the isolated level of transactions.

Based on the ANSI/ISO SQL specification, MySQL provides four isolation levels:

SERIALIZABLE (serialization)

REPEATABLE READ (reread)

READ COMMITTED (read after submission)

READ UNCOMMITTED (read not submitted)

Modify the isolated level of a transaction

In MySQL, you can use the TRANSACTION ISOLATION LEVEL variable to modify the transaction isolation level, where the default isolation level of MySQL is REPEATABLE READ (readable), and the user can use the SELECT command to get the value of the current transaction isolation level variable

The command is as follows:

SELECT @ @ tx_isolation

Query cache

In MySQL, apply the VARIABLES keyword to view the server variables as wildcards.

Use caching

In MySQL, the specific syntax structure of the query cache is as follows:

SELECT SQL_CACHE * FROM table name

The data table is then queried without using the cache.

Tags: Transaction variable data user cache high-speed database query behavior different command server application impact service necessary two key keyword trend Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Apple MariaDB Redmi