sql-server – SQL Server的READ COMMITTED SNAPSHOT vs SNAPSHOT

前端之家收集整理的这篇文章主要介绍了sql-server – SQL Server的READ COMMITTED SNAPSHOT vs SNAPSHOT前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在研究sql Server的READ COMMITTED SNAPSHOT和SNAPSHOT隔离级别之间的差异,并且遇到了以下资源:

Choosing Row Versioning-based Isolation Levels

For most applications,read committed isolation using row versioning
is recommended over snapshot isolation for the following reasons:

  • It consumes less tempdb space than snapshot isolation.

  • Snapshot isolation is vulnerable to update conflicts that are not applicable to read committed isolation using row versioning. When a
    transaction running under snapshot isolation reads data that is then
    modified by another transaction,an update by the snapshot transaction
    to the same data causes an update conflict and the transaction
    terminates and rolls back. This is not an issue with read committed
    isolation using row versioning.

我对这些主题不太了解,但我似乎无法理解上面链接中的两个要点.

>为什么这些模式的t​​empdb空间不同?是否存储比其他版本更精细的版本控制?
>为什么快照隔离更容易受到更新冲突的影响?

解决方法

> READ COMMITTED SNAPSHOT在每个语句后使用新快照.这意味着更少的行版本保持活着. (您从文档中引用的语句略有误导,因为它表明这始终是正确的 – 只有在长时间运行的SNAPSHOT事务中才会出现这种情况.)在写入时创建快照行版本.读取不影响放入tempdb的内容.作家不可能预见将来会进行哪些阅读.读者只会影响可以清除的内容. >当SNAPSHOT事务T1在T1启动和T1尝试写入之间的时间内写入由另一个事务T2修改的行时,该语句将失败并显示更新冲突错误.这是一种乐观的并发模型.使用READ COMMITTED SNAPSHOT T1将等待T2释放行上的X锁并继续正常.
原文链接:https://www.f2er.com/mssql/79878.html

猜你在找的MsSQL相关文章