开发者

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

开发者 https://www.devze.com 2023-04-12 08:16 出处:网络
I am trying to figure out which isolation level (among serializable and read committed )is betterin what scenarios..At link http://download.oracle.com/docs/cd/B14117_01/server.101/b10743/consist.htm#i

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.

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.

Question1:- How Read committed isolation provides more concurrency than serializable?As per myunderstanding serializable transactions also does not restrict concurrent transactions.

Statement:- All queries in an Oracle serializable transaction see the database as of a single point in time

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.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

Question:- Say two transactions tran1 and tran2 begin at time t1. If tran1 updates the the row1 at time t2 and lat开发者_JS百科er at time t3 tran2 fetches the same row will tran2 get the updated row done by tran1 ? (i think no because tran2 will fetch the state of data which was present at time t1.Right?)

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. If tran1 updates the row1 at time t2 and later at time t3 tran2 updates the same 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?


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. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消