| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

11-23-04, 08:22
|
|
Registered User
|
|
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
|
|
|
DB2 locking vs. Oracle locking
|
|
I was reading about Oracle's locking model, maybe someone here knows a bit about both and can clarify.
According to the article, Oracle doesn't block reads while an application updates rows! (or vice versa)
While I'm sure this is great for concurrency, it seems to me that it gives inaccurate results...
ie:
Oracle:
Application 1 - updates row (no commit)
Application 2 - reads row (gets old data!)
DB2:
Application 1 - updates row (no commit)
Application 2 - reads row, blocks
Application 1 - commit
Application 2 - gets new data
(Unless using UR)
So it seems like a fundamental difference as to when a change takes place... in DB2 the row is deemed to have changed when the statement is issued, in Oracle it's deemed to have changed when the statement is committed.
Is my understanding accurate?
__________________
--
Jonathan Petruk
DB2 Database Consultant
|
|

11-23-04, 09:05
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
I think your understanding is correct. It is recommended when developing with Oracle to re-read the record that you're about to update using "FOR UPDATE" clause - basically, use optimistic locking strategy.
|
|

11-23-04, 09:11
|
|
Registered User
|
|
Join Date: Jan 2004
Location: Europe, Finland, Helsinki
Posts: 60
|
|
|
|
Yes!
Your understanding is all correct. In Oracle, an update will create a new version of the data and a commit will allow others to see it. Old data can now discarded. However, for recovery needs Oracle needs also logging.
- If a rollback is needeed, this new data is just discarded.
In DB2 when you do an update, DB2 log saves old version and then data will be overwritten. However, others may not see this new data, until a commit is issued.
- If a rollback is needeed, DB2 fetch old version fron the log and rewrite old data back.
Cheers, Bill
|
|

11-23-04, 09:15
|
|
Registered User
|
|
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
|
|
Very interesting, thanks.
__________________
--
Jonathan Petruk
DB2 Database Consultant
|
|

11-23-04, 10:06
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 237
|
|
Stinger and DB2_EVALUNCOMMITTED registry variable. With this variable enabled, predicate evaluation can occur on uncommitted data. This means that a row that contains an uncommitted update may not satisfy the query, whereas if the predicate evaluation waited until the updated transaction completed, the row may satisfy the query.
__________________
mota
|
|

08-05-09, 03:51
|
|
Registered User
|
|
Join Date: May 2009
Posts: 1
|
|
How we can check the table locking in the DB2 Z OS? How we can avoid it?
|
|

08-05-09, 05:31
|
|
Registered User
|
|
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
|
|
If you are concerned about accuracy in an Oracle environment, you should know that Oracle has a SERIALIZABLE isolation level that is, somehow, similar to DB2 RR isolation level. Although the internal mechanisms for assuring isolation are quite different, yes.
__________________
Florin Aparaschivei
Iasi, Romania
|
|

08-05-09, 08:21
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
Quote:
|
Originally Posted by aflorin27
If you are concerned about accuracy in an Oracle environment, you should know that Oracle has a SERIALIZABLE isolation level that is, somehow, similar to DB2 RR isolation level. Although the internal mechanisms for assuring isolation are quite different, yes.
|
The posts about Oracle (and DB2) prior to the most recent post about Db2 for z/OS before yours, are almost 5 years old.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
|
|

08-05-09, 08:37
|
|
Registered User
|
|
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
|
|
Sorry  I usually read the new post - so I didn't pay attention to the first posts' dates.
__________________
Florin Aparaschivei
Iasi, Romania
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|