dbTalk Databases Forums  

Transaction and locks

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss Transaction and locks in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chakravarthy
 
Posts: n/a

Default Transaction and locks - 01-11-2007 , 11:54 PM






This may be a naive question. Since DB Transactions with higher isolation
levels internally use locks, does it make sense to use Transactions for
concurrency management , in place of using some kind of pessimistic locks ?

Thanks,
Raj.



Reply With Quote
  #2  
Old   
Dejan Sarka
 
Posts: n/a

Default Re: Transaction and locks - 01-12-2007 , 01:03 AM






Huh... You should read a bit more about transactions in Books OnLine. You
have some misconcepts here.

Quote:
This may be a naive question. Since DB Transactions with higher isolation
levels internally use locks,
All transactions use locks, even in read uncommitted level you get exclusive
locks for updates.

Quote:
does it make sense to use Transactions for concurrency management , in
place of using some kind of pessimistic locks ?
In SQL Server, all updates are automatically transactions. You should
specify your own transactions when you need higher grain of atomicity, i.e.
if you want to have more than one update joined in a single transaction, so
all updates are committed or all are rolled back. Locks are the mechanism
for concurrency management. Some isolation levels (read uncommitted, read
committed, repeatable read, serializable) are pessimistic, some (read
committed snapshot, snapshot) are optimistic. It is not locks that define
whether the locking is optimistic or pessimistic; it is the fact whether you
have more than one copy of the same data or not.

--
Dejan Sarka
http://www.solidqualitylearning.com/blogs/




Reply With Quote
  #3  
Old   
Mary Chipman [MSFT]
 
Posts: n/a

Default Re: Transaction and locks - 01-15-2007 , 01:30 PM



In addition to what Dejan said, you should always try to avoid using
pessimistic locking in your applications. There is no simple
one-size-fits-all solution because every application is different.
However, designing your table schema at the outset with concurrency in
mind can eliminate locking and blocking headaches down the road.

--Mary

On Fri, 12 Jan 2007 11:24:56 +0530, "Chakravarthy"
<r_chakravarthy (AT) hotmail (DOT) com> wrote:

Quote:
This may be a naive question. Since DB Transactions with higher isolation
levels internally use locks, does it make sense to use Transactions for
concurrency management , in place of using some kind of pessimistic locks ?

Thanks,
Raj.


Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.