Re: Transaction and locks



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

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.

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/


.



Relevant Pages

  • Re: Timeout Expired for no apparent reason
    ... I checked for locks during the execution. ... I did not define any transactions ... The reason why I'm doing it in a DLL is that when I do it in a stored ... avoid this by doing updates one at a time. ...
    (microsoft.public.sqlserver.clients)
  • Re: MATREADU/MATWRITE statements timing out
    ... Pessimistic locks for transactions (required for transaction ... Optimistic locks for "masterfile updates" (which 'deteriorate' to ... field by field comparisons during actual update, ...
    (comp.databases.pick)
  • Re: Sql Server Locks
    ... Tran and Commit Tran are as close together as possible and the transactions ... > The problem is with SQL Server Database Locks. ... > client A and reinserts the same with some data changes ... > provide us any good links for this kind of scenarios. ...
    (microsoft.public.sqlserver.clients)
  • Re: can you tell me why this causes a deadlock?
    ... you need to ensure you obtain all the locks required for the whole ... Session 1: ... insert into joe with values ... what two locks my original two transactions got in reverse ...
    (comp.databases.ms-sqlserver)
  • Re: SqlDataReader default locking?
    ... Let's imagine we perform the 4 following transactions one after the other ... > sub-second response time where locks are held for the minimum amount ... > hold or honor any locks, and can give you dirty reads. ... >>I just wanted to know wheter any row locking takes place when we are ...
    (microsoft.public.dotnet.framework.adonet)