473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

serializable read and lock mode

Hi,

Version Info: SQLSERVER 2000 SP3

I am trying to understand how SQL Server works with SERIALIZABLE read.
I am fairly new to SQL Server, having mainly worked with Informix.
We are getting lock timeout error in our application. Our lock timeout
is set to 20 seconds. I am trying to investigate why locks are held for
such a long time in the first place.

I believe SQLServer tries to put keylocks as much as possible for
ensuring serializibility. For e.g.
SELECT column_b
from table_a
where column_c between 1000 and 1100

what if column_c has no index. Does it switch over the data row.
And what if a table has no index. Will it go for table lock, as it
use to do in earlier versions.

TIA.

--

email id is bogus
Jul 20 '05 #1
3 5609
rkusenet (rk******@sympatico.ca) writes:
I am trying to understand how SQL Server works with SERIALIZABLE read.
I am fairly new to SQL Server, having mainly worked with Informix.
We are getting lock timeout error in our application. Our lock timeout
is set to 20 seconds. I am trying to investigate why locks are held for
such a long time in the first place.

I believe SQLServer tries to put keylocks as much as possible for
ensuring serializibility. For e.g.
SELECT column_b
from table_a
where column_c between 1000 and 1100


For this query, SQL Server will take a range lock if column_c is
indexed.

If there is no index, SQL Server will have to lock the table as far as
I can understand, as serializable means that you to do permit anyone
to insert a row with a value in this range until the transaction is
committed.


--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

"Erland Sommarskog" <so****@algonet.se> wrote
I am trying to understand how SQL Server works with SERIALIZABLE read.
I am fairly new to SQL Server, having mainly worked with Informix.
We are getting lock timeout error in our application. Our lock timeout
is set to 20 seconds. I am trying to investigate why locks are held for
such a long time in the first place.

I believe SQLServer tries to put keylocks as much as possible for
ensuring serializibility. For e.g.
SELECT column_b
from table_a
where column_c between 1000 and 1100


For this query, SQL Server will take a range lock if column_c is
indexed.

If there is no index, SQL Server will have to lock the table as far as
I can understand, as serializable means that you to do permit anyone
to insert a row with a value in this range until the transaction is
committed.


I checked it and it is indeed correct. In the above example, if there
is no index on column_c (even if there are indexes on other fields),
a table lock will be used to achieve serializability.

Are there any other conditions when a table lock will be used.

Thanks for your help.

--

email id is bogus
Jul 20 '05 #3
rkusenet (rk******@sympatico.ca) writes:
I checked it and it is indeed correct. In the above example, if there
is no index on column_c (even if there are indexes on other fields),
a table lock will be used to achieve serializability.

Are there any other conditions when a table lock will be used.


Well, an obvious case is

SELCET * FROM tbl

For the case you an bounded interval, I don't really know. I would expect
that a range lock will do, but if the query is complex there may be good
reasons to use a table lock instead. But that may be the logic of the query
is such that it actually covers the entire table.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: pb648174 | last post by:
I have a very long transaction that runs on the same database that other users need to use for existing data. I don't care if they see data from the transaction before it is done and am only using...
3
by: Magnus Byne | last post by:
Hi, I have a problem using serializable transactions. In one transaction I select a single specific row from a table using a where clause (this causes it to acquire and hold a range lock). In...
2
by: xixi | last post by:
i am using type 4 driver with fp3 on windows 64bit server, auto commit is true, cursor is CS type. i have a sensitive , updatable cursor open and bring back a one row resultset, i get this...
0
by: Bruce Pullen | last post by:
DB2 v7.2 (FP7 - DB2 v7.1.0.68) on AIX 5.2.0.0. We're seeing unexpected single row (then commit) insert locking behaviour. We're seeing Applications that already hold row-level W locks in...
5
by: harborboy76 | last post by:
Hi all, First of all, just want to let you know that I'm coming from Informix background, and we just recently migrated to DB2. It's been a great new learning experience. For the time being, I...
3
by: Raghavendra Tilve | last post by:
Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'. Description: An...
3
by: Raj | last post by:
I created a refresh deferred MQT, and during full refresh there were 4 or 5 lock waits, all waiting on a 'S' lock on Internal Catalog Cache ? Can some one explain how to prevent this from happening?
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
6
by: michael.spoden | last post by:
Hi, how can I fix lock-waits during an online backup? Is an online backup in DB2 V8.2 not realy online? I'm using DB2 V8.2 Fixpak 15 on Linux. The command to perform the backup is: db2 backup...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.