设置ALTER DATABASE [数据库名称] SET READ_COMMITTED_SNAPSHOT ON后为什么update还会影响select效率呢?
时间: 2024-04-28 14:21:29 浏览: 14
在 SQL Server 中,设置 READ_COMMITTED_SNAPSHOT 为 ON 后,可以实现快照隔离。这意味着在进行读操作时,不会阻塞写操作,而是读取已经提交的数据快照。因此,读操作不会受到写操作的影响,可以提高并发性能。
但是,在进行大量 UPDATE 操作时,会导致事务版本链的增长,因此可能会影响 SELECT 查询的性能。因为 SELECT 查询需要检查版本链,以确保读取的数据是已提交的数据快照。如果版本链过长,查询将需要更多的时间来查找正确的数据快照。
因此,即使开启了 READ_COMMITTED_SNAPSHOT,也需要注意避免过度的 UPDATE 操作,以确保查询性能不受影响。
相关问题
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE sdle9 SET READ_COMMI' at line 1是什么意思
这个错误提示意思是你的 SQL 语法有错误,MySQL 数据库无法识别你输入的语句。具体错误是在语句中的 "SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE sdle9 SET READ_COMMITTED_SNAPSHOT ON" 处,MySQL 不知道 "GO" 这个关键字是什么意思,因此报错。
你需要检查你的 SQL 语句,确保它们符合 MySQL 的语法规范。通常来说,你可以通过 MySQL 官方文档或者其他参考资料来了解 MySQL 支持的 SQL 语法。同时,也可以尝试使用分号 (;) 代替 "GO" 关键字来分隔多条 SQL 语句。
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO ALTER DATABASE sdle9 SET READ_COMMI' at line 1
It seems like you are trying to execute multiple SQL statements at once. The first statement is incomplete and the second statement is not properly separated from the first one.
To fix this error, you should separate each SQL statement with a semicolon (;) and execute them one by one. Here is an example:
```
SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE sdle9 SET READ_COMMITTED_SNAPSHOT ON;
```
This will execute the first statement to set the database in single-user mode and roll back any active transactions. Then, the second statement will set the database to use the read committed snapshot isolation level.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)