简体   繁体   English

应该使用Read committed或Serializable作为隔离级别的场景?

[英]Scenario where one should use Read committed or Serializable as Isolation level?

I am trying to figure out which isolation level (among serializable and read committed )is better in what scenarios..At link http://download.oracle.com/docs/cd/B14117_01/server.101/b10743/consist.htm#i17894 , I was going thru topic choice of isolation level , I got some clarity and some questions based on some statements in the article. 我试图找出哪些隔离级别(可序列化和读取提交)在哪些情况下更好..链接http://download.oracle.com/docs/cd/B14117_01/server.101/b10743/consist.htm #i17894 ,我通过主题选择隔离级别 ,我得到了一些清晰度和一些基于文章中的一些陈述的问题。

Satement :- Read committed isolation can provide considerably more concurrency with a somewhat increased risk of inconsistent results due to phantoms and non-repeatable reads for some transactions. Satement : - 读取已提交的隔离可以提供更多的并发性,并且由于某些事务的幻像和不可重复读取而导致结果不一致的风险略有增加。

Question1:- How Read committed isolation provides more concurrency than serializable?As per myunderstanding serializable transactions also does not restrict concurrent transactions. 问题1: - Read committed isolation如何提供比serializable更多的并发性?根据我的理解,可序列化事务也不会限制并发事务。

Statement:- All queries in an Oracle serializable transaction see the database as of a single point in time 声明: - Oracle可序列化事务中的所有查询都会在单个时间点查看数据库

Question:- I think what they mean here , when serializable transaction begin say at time t1 then all the data will be presented from the state of Database which was at time t1. 问题: -我认为这里的意思是,当可序列化的事务开始在时间t1说,然后所有数据将从时间t1的数据库状态呈现。 Right? 对? Not sure when we call the transaction actually begins. 不确定我们何时调用交易实际开始。 Is it when we get the connection or when first query is fired? 是在我们获得连接或第一次查询被触发时?

Statement:- Oracle's serializable isolation is suitable for environments where there is a relatively low chance that two concurrent transactions will modify the same rows and the long-running transactions are primarily read only 声明: - Oracle的可序列化隔离适用于两个并发事务修改相同行的可能性相对较低且长时间运行的事务主要是只读的环境

Question:- Say two transactions tran1 and tran2 begin at time t1. 问题: -假设两个交易tran1和tran2在时间t1开始。 If tran1 updates the the row1 at time t2 and later at time t3 tran2 fetches the same row will tran2 get the updated row done by tran1 ? 如果tran1在时间t2更新row1并且稍后在时间t3更新tran2获取同一行将tran2获取由tran1完成的更新行? (i think no because tran2 will fetch the state of data which was present at time t1. Right? ) (我认为没有,因为tran2将获取在时间t1出现的数据状态。 对吧?

Statement:- Coding serializable transactions requires extra work by the application developer to check for the "Cannot serialize access" error and to undo and retry the transaction. 声明: -编码可序列化事务需要应用程序开发人员进行额外的工作,以检查“无法序列化访问”错误并撤消并重试事务。

Question:- Not sure when developer will get “Cannot serialize access” error. 问题: -不确定开发人员何时会收到“无法序列化访问”错误。 Will we get the same error in below scenario 在下面的场景中我们会得到同样的错误吗?

Say two transactions tran1 and tran2 begin at time t1. 假设两个事务tran1和tran2在时间t1开始。 If tran1 updates the row1 at time t2 and later at time t3 tran2 updates the same row1. 如果tran1在时间t2更新row1并且稍后在时间t3更新tran2则更新相同的row1。 Will it throw the “Cannot serialize access” error in this case? 在这种情况下,它会抛出“无法序列化访问”错误吗? If yes Does oracle maintain the version internally in case of serializable transactions so that it gets to know row has been updated by user? 如果是,oracle是否在内部维护版本以防可序列化事务,以便知道用户已更新行?

If you want to see committed data, choose read committed. 如果要查看已提交的数据,请选择“已提交读取”。 Each query could see different committed data. 每个查询都可以看到不同的提交数据

If you want to see the same results for multiple queries, choose serializable. 如果要查看多个查询的相同结果,请选择serializable。 The same results will be returned until your transaction ends. 在您的交易结束之前,将返回相同的结果。

Both have limits. 两者都有限制。 Choose the isolation level that is needed. 选择所需的隔离级别。 Do not choose an isolation level that does more than you need. 不要选择超出您需要的隔离级别。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在“读取提交的隔离级别”下进行更新? - Update under Read committed Isolation level? 我应该使用哪个事务隔离级别进行读取语句? - Which Transaction isolation level should i use for read statement? app srv隔离级别设置为READ COMMITTED时是否会发生OptimisticLockException? - can OptimisticLockException occur if app srv Isolation level is set to READ COMMITTED? Oracle数据库中的READ_COMMITTED和SERIALIZABLE隔离级别有什么区别? - What's the difference between READ_COMMITTED and SERIALIZABLE isolation levels in Oracle database? 如果我需要第二次读取版本,为什么要使用可重复读取(或更高)隔离级别? - Why should I use Repeatable Read(or higher) isolation level if I need to read version the second time? JDBC事务如何在TRANSACTION_READ_COMMITTED隔离级别锁定表? - How does JDBC Transaction lock a table in TRANSACTION_READ_COMMITTED isolation level? Spring Kafka:kafkaTemplate executeInTransaction 方法如何发挥 Consumer 的 read_committed 隔离级别 - Spring Kafka: How does kafkaTemplate executeInTransaction method play with Consumer's read_committed isolation level 为什么 mysql JDBC 驱动程序返回 TRANSACTION_READ_COMMITTED 作为默认隔离级别 - Why mysql JDBC driver returns TRANSACTION_READ_COMMITTED as default isolation level 在Neo4j中,默认隔离级别是否始终为READ_COMMITTED,还是仅当使用Java扩展时才如此? - In Neo4j is the default isolation level always READ_COMMITTED or is it the case only when extending it with Java? Spring-JDBC中的隔离级别SERIALIZABLE - Isolation level SERIALIZABLE in Spring-JDBC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM