gpt4 book ai didi

mysql - 如何将MySQL中的InnoDB设置为快照隔离级别

转载 作者:可可西里 更新时间:2023-11-01 07:28:45 25 4
gpt4 key购买 nike

我现在正在开展一个学校项目,该项目需要表征 MySQL 在不同隔离级别方面的性能。我已经测试了 READ UNCOMMITTED、READ COMMITTED、REPEATABLE READ 和 SERIALIZABLE。现在我想使用快照隔离进行测试。

我知道在InnoDB中使用默认的REPEATABLE READ时,会结合使用快照隔离,但我想知道,是否可以将隔离级别设置为仅快照隔离?我该怎么做?

最佳答案

没有全局快照隔离级别。来自 MySQL 文档,START TRANSACTION语法:

You can also begin a transaction like this:

START TRANSACTION WITH CONSISTENT SNAPSHOT;

The WITH CONSISTENT SNAPSHOT option starts a consistent read for storage engines that are capable of it. This applies only to InnoDB. The effect is the same as issuing a START TRANSACTION followed by a SELECT from any InnoDB table. See Section 13.6.8.2, “Consistent Nonlocking Reads”. The WITH CONSISTENT SNAPSHOT option does not change the current transaction isolation level, so it provides a consistent snapshot only if the current isolation level is one that permits consistent read (REPEATABLE READ or SERIALIZABLE).

因此,您必须将隔离级别设置为 REPEATABLE READSERIALIZABLE 并使用上述语法开始您的事务。

关于mysql - 如何将MySQL中的InnoDB设置为快照隔离级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9880555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com