Hi All,
According to my observation using SP_WHO2 in my database, some INSERT
statements are getting blocked by SELECT statements. Though the
blocking
SELECT statement is having ReadPast hint, i think, it will only read
past
locked resources but will not guarantee the select statement itself not
blocking other statements(in my case Insert). According to my knowledge
and
information, select statements take shared locks but why then these
statements are blocking insert statements?
Can there be any other solution other than using NoLock hint as this
hint
make sure no shared locks are issued but it can read uncommited data.
Need help urgently.
Thanks
Ritesh 5 5446
Ritesh,
ReadPast only skips row level locks. sp_who2 will not show you the
granularity of the lock for that use sp_lock. You are correct that only
NoLock will read without blocking but it comes with a price of potentially
reading dirty pages. In SQL 2005 a new isolation level will be added called
SnapShot that will give you what you are looking for.
Ray
"Ritesh" <ri**************@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com... Hi All,
According to my observation using SP_WHO2 in my database, some INSERT statements are getting blocked by SELECT statements. Though the blocking SELECT statement is having ReadPast hint, i think, it will only read past locked resources but will not guarantee the select statement itself not blocking other statements(in my case Insert). According to my knowledge
and information, select statements take shared locks but why then these statements are blocking insert statements?
Can there be any other solution other than using NoLock hint as this hint make sure no shared locks are issued but it can read uncommited data.
Need help urgently.
Thanks Ritesh
Thanks Ray,
Can there be any solutions to SELECT statements not blocking Insert statements?
Regards,
Ritesh
"Ray" <so*****@nowhere.com> wrote in message news:<Ns*******************@newssvr33.news.prodigy .com>... Ritesh,
ReadPast only skips row level locks. sp_who2 will not show you the granularity of the lock for that use sp_lock. You are correct that only NoLock will read without blocking but it comes with a price of potentially reading dirty pages. In SQL 2005 a new isolation level will be added called SnapShot that will give you what you are looking for.
Ray
"Ritesh" <ri**************@yahoo.com> wrote in message news:11*********************@g14g2000cwa.googlegro ups.com... Hi All,
According to my observation using SP_WHO2 in my database, some INSERT statements are getting blocked by SELECT statements. Though the blocking SELECT statement is having ReadPast hint, i think, it will only read past locked resources but will not guarantee the select statement itself not blocking other statements(in my case Insert). According to my knowledge
and information, select statements take shared locks but why then these statements are blocking insert statements?
Can there be any other solution other than using NoLock hint as this hint make sure no shared locks are issued but it can read uncommited data.
Need help urgently.
Thanks Ritesh
Pehaps you are asking the wrong question. I would be asking why the select
queries are running long enough to block the update queries. If applications
are written correctly then select queries should run quickly enough that
updates are not blocked for long.
Specifically in 2000 you can only use nolock or set the the isoation level
to dirty read for the query (does the same), you cannot guarantee to get
clean data if you do this. It will depend on what the users need if this is
acceptable.
Shared locks will block update locks this is correct and expected. Also SQL
2000 will only allow exclusive locks to be blocked 4 times (from memory) by
shared locks before it lets the exclusive locks through (this gives further
weight to the question as to why the select queries are taking so long)
Help this helps
Julian
"Ritesh" <ri**************@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com... Hi All,
According to my observation using SP_WHO2 in my database, some INSERT statements are getting blocked by SELECT statements. Though the blocking SELECT statement is having ReadPast hint, i think, it will only read past locked resources but will not guarantee the select statement itself not blocking other statements(in my case Insert). According to my knowledge
and information, select statements take shared locks but why then these statements are blocking insert statements?
Can there be any other solution other than using NoLock hint as this hint make sure no shared locks are issued but it can read uncommited data.
Need help urgently.
Thanks Ritesh
Ritesh,
Normally insert statement will not block on select statement. But there are
exceptions. For example, when the lock granularity of the insert is the
page level, then it can block on page lock held by select statement. If
this is the case, the force insert to take row lock using ROWLOCK will
remove the blocking. Or if the select statement is run under read repeatable
or serializable isolation level, then the select takes some kind of key
range lock which prevents insert into the range locked. If this is the
case, changebthe select isolation level to read committed will remove
blocking. Finally you may need to do some homework to find out which lock
the insert is blocked on by the select, which you can query sysprocesses and
syslockinfo to find out.
--
Gang He
Software Design Engineer
Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Ritesh" <ri**************@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com... Hi All,
According to my observation using SP_WHO2 in my database, some INSERT statements are getting blocked by SELECT statements. Though the blocking SELECT statement is having ReadPast hint, i think, it will only read past locked resources but will not guarantee the select statement itself not blocking other statements(in my case Insert). According to my knowledge
and information, select statements take shared locks but why then these statements are blocking insert statements?
Can there be any other solution other than using NoLock hint as this hint make sure no shared locks are issued but it can read uncommited data.
Need help urgently.
Thanks Ritesh
Hi,
You are correct but the problem is my select queries are blocking
insert statements and select statements are running in default
isolation level. The problem is, I inheriated this design, which is
OLTP in nature but the DB is also queried extensively for newly
inserted records.
Can there be any way to completely avoid just inserting records
(showing in the query. It is acceptable for business logic, say
READPAST will do.) and also the query (same select query) not blocking
newly inserting records but not reading any dirty data? or I am asking
to much from SQL Server? :)
What do you say?
Thanks & Regards,
Ritesh Khanna
"Gang He [MSFT]" <ga**************@microsoft.com> wrote in message news:<42********@news.microsoft.com>... Ritesh,
Normally insert statement will not block on select statement. But there are exceptions. For example, when the lock granularity of the insert is the page level, then it can block on page lock held by select statement. If this is the case, the force insert to take row lock using ROWLOCK will remove the blocking. Or if the select statement is run under read repeatable or serializable isolation level, then the select takes some kind of key range lock which prevents insert into the range locked. If this is the case, changebthe select isolation level to read committed will remove blocking. Finally you may need to do some homework to find out which lock the insert is blocked on by the select, which you can query sysprocesses and syslockinfo to find out.
-- Gang He Software Design Engineer Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights. "Ritesh" <ri**************@yahoo.com> wrote in message news:11*********************@g14g2000cwa.googlegro ups.com... Hi All,
According to my observation using SP_WHO2 in my database, some INSERT statements are getting blocked by SELECT statements. Though the blocking SELECT statement is having ReadPast hint, i think, it will only read past locked resources but will not guarantee the select statement itself not blocking other statements(in my case Insert). According to my knowledge
and information, select statements take shared locks but why then these statements are blocking insert statements?
Can there be any other solution other than using NoLock hint as this hint make sure no shared locks are issued but it can read uncommited data.
Need help urgently.
Thanks Ritesh This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ryan |
last post by:
I have a problem with record locking / blocking within an application.
The app is quite straight forward. Written in Delphi 5 using BDE to
access a SQL 7 database (Win2K server).
Every so often...
|
by: john smile |
last post by:
Hi All,
I want to lock 2 tables on 2 servers using TABLOCKX
hint. These tables function as semaphores in my
application. It means when the tables are locked
then other users will not be able to...
|
by: Randall Sell |
last post by:
Hello all,
Somewhere on these newsgroups I recall reading that SQL Server 6 and prior
(when they were married with Sybase) used page locking and not row level
locking. Hence you could be locking...
|
by: Nid |
last post by:
How do I do row-level locking on SQL Server?
Thanks,
Nid
|
by: Wolfgang Bachmann |
last post by:
We migrated a database from Version 5.1 to 8.1 and are experiencing
massive locking problems. We migrated in the following steps:
0) Server 5.2, Clients 5.2: everithing was fine
1) Server 5.2,...
| |
by: Shaun |
last post by:
Ok here is the situation…
Have an access 20002 application that I'm converting to have a SQL
Server backend (2000), the application has been in use with an access
backend for years, no real...
|
by: z. f. |
last post by:
Hi,
i have an ASP.NET project that is using a (Class Library Project) VB.NET DLL.
for some reason after running some pages on the web server, and trying to compile the Class Library DLL, it...
|
by: Shak |
last post by:
Hi all,
I'm trying to write a thread-safe async method to send a message of the form
(type)(contents). My model is as follows:
private void SendMessage(int type, string message)
{
//lets...
|
by: David C. Barber |
last post by:
How do you lock a record in SQL Server from ASP 2? I need to read the
record, allow the user to edit it, and then have them click Save and rewrite
it. Obviously I don't want anyone else getting...
|
by: zmickle |
last post by:
Experts and books all say that you can share an Access back end on a
shared
drive with the front end running on each host computer. I have a
simple
database that tracks student data and it is...
|
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,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |