Vla*_*cea 15 database postgresql transactions readonly database-concurrency
根据参考文档,除了允许DEFERRABLE事务之外,READ ONLY事务标志是有用的吗?
SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;
Run Code Online (Sandbox Code Playgroud)
除非事务也是SERIALIZABLE和READ ONLY,否则DEFERRABLE事务属性不起作用.当为事务选择所有这三个属性时,事务可能会在第一次获取其快照时阻塞,之后它可以在没有SERIALIZABLE事务的正常开销的情况下运行,并且没有任何可能导致序列化或被序列化取消的风险失败.此模式非常适合长时间运行的报告或备份.
数据库引擎是否为只读事务运行其他优化?
总结Nick Barnes和Craig Ringer在评论中的评论:
小智 7
事实上,确实如此。让我在这里引用源代码注释:
/*
* Check if we have just become "RO-safe". If we have, immediately release
* all locks as they're not needed anymore. This also resets
* MySerializableXact, so that subsequent calls to this function can exit
* quickly.
*
* A transaction is flagged as RO_SAFE if all concurrent R/W transactions
* commit without having conflicts out to an earlier snapshot, thus
* ensuring that no conflicts are possible for this transaction.
*/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2645 次 |
| 最近记录: |