February 8, 2017 at 9:40 am
So we have a server which has user tables in the master database (I know that is not a good idea), they are constantly getting deadlocks shown here
left statement
right statement
So 2 select statements at the same time on the same table causing a deadlock. I didn't think this was possible?
February 8, 2017 at 10:04 am
John Mitchell-245523 - Wednesday, February 8, 2017 9:52 AMYeah, it's possible. Work through this - it should get you to the cause. Just as a matter of interest, how many rows are in the table and what indexes are on it?John
At this time there are no rows in the table. I think someone is using it for concurrency or something. There are 6 indexes with 1 of them being clustered. The requests come in exactly at the same time to the millisecond.
February 8, 2017 at 11:22 am
could it be that the construction of the query, where it says COLUMNNAME IN(singlevalue) causes a range scan, where if it was COLUMNNAME = singlevalue , it would be an index lookup, and that is causing the deadlocks?
Lowell
February 9, 2017 at 10:52 am
as i recall it you shouldnt be seeing a lock mode of X for a select statement, SQL Server lock modes
Can you provide more detail of the queries that are being executed and full details of the indexes on the table
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
February 9, 2017 at 12:59 pm
Perry Whittle - Thursday, February 9, 2017 10:52 AMas i recall it you shouldnt be seeing a lock mode of X for a select statement, SQL Server lock modes
Can you provide more detail of the queries that are being executed and full details of the indexes on the table
There are indexes but there are often no rows in the table most of the time. Something is inserting a row, it persists for a few seconds, then its gone. I don't know much about the application. The queries are listed above and the indexes are
clustered primary key with 3 fields. Not sure what is inserting and deleting the records.
The table has 5 non clustered indexes on the other fields, each with one column so that accounts for the 8 columns of the entire table. I don't understand why it was set up that way but I think a noob put this thing together.
February 9, 2017 at 3:04 pm
Perry Whittle - Thursday, February 9, 2017 10:52 AMas i recall it you shouldnt be seeing a lock mode of X for a select statement, SQL Server lock modes
Can you provide more detail of the queries that are being executed and full details of the indexes on the table
At a guess, either the SELECT is WITH (XLOCK), or there's an insert within the transaction that we're not seeing, and so it'll show the SELECT to have an XLock, because that's the lock that the session holds
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
February 10, 2017 at 5:09 am
GilaMonster - Thursday, February 9, 2017 3:04 PMor there's an insert within the transaction that we're not seeing
This was my train of thought Gail, there's something else we're not seeing
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply