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.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 locking vs. Oracle locking

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-04, 08:22
J Petruk J Petruk is offline
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
Reply With Quote
  #2 (permalink)  
Old 11-23-04, 09:05
n_i n_i is offline
:-)
 
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.
Reply With Quote
  #3 (permalink)  
Old 11-23-04, 09:11
hurmavi hurmavi is offline
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
Reply With Quote
  #4 (permalink)  
Old 11-23-04, 09:15
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Very interesting, thanks.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #5 (permalink)  
Old 11-23-04, 10:06
dbamota dbamota is offline
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
Reply With Quote
  #6 (permalink)  
Old 08-05-09, 03:51
harmeet1759 harmeet1759 is offline
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?
Reply With Quote
  #7 (permalink)  
Old 08-05-09, 05:31
aflorin27 aflorin27 is offline
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
Reply With Quote
  #8 (permalink)  
Old 08-05-09, 08:21
Marcus_A Marcus_A is offline
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
Reply With Quote
  #9 (permalink)  
Old 08-05-09, 08:37
aflorin27 aflorin27 is offline
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On