Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Mysterious deadlocks on a heap table


Mysterious deadlocks on a heap table

Author
Message
Eirikur Eiriksson
Eirikur Eiriksson
SSCertifiable
SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)

Group: General Forum Members
Points: 6766 Visits: 17739
I've come across this problem few times in the recent past and found that Implicit conversion from CHAR/VARCHAR to NCHAR/NVARCHAR and vice versa, will cause Index Scans which can lead to deadlocking.
Cool
TheSQLGuru
TheSQLGuru
SSCertifiable
SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)

Group: General Forum Members
Points: 5990 Visits: 8314
Eirikur Eiriksson (7/5/2014)
I've come across this problem few times in the recent past and found that Implicit conversion from CHAR/VARCHAR to NCHAR/NVARCHAR and vice versa, will cause Index Scans which can lead to deadlocking.
Cool


That isn't under dispute and certainly can be a DEVASTATINGLY bad thing from a bunch of different perspectives. But Jeff/Gail were speaking about mismatches between CHAR and VARCHAR - nothing about Unicode conversion there.

Best,

Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru at GMail
Eirikur Eiriksson
Eirikur Eiriksson
SSCertifiable
SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)SSCertifiable (6.8K reputation)

Group: General Forum Members
Points: 6766 Visits: 17739
TheSQLGuru (7/5/2014)
Eirikur Eiriksson (7/5/2014)
I've come across this problem few times in the recent past and found that Implicit conversion from CHAR/VARCHAR to NCHAR/NVARCHAR and vice versa, will cause Index Scans which can lead to deadlocking.
Cool


That isn't under dispute and certainly can be a DEVASTATINGLY bad thing from a bunch of different perspectives. But Jeff/Gail were speaking about mismatches between CHAR and VARCHAR - nothing about Unicode conversion there.


Ooops, this time I'll blame it on the jet lagDoze
Cool
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45203 Visits: 39925
Jeff Moden (7/5/2014)
GilaMonster (7/5/2014)
Jeff Moden (7/4/2014)
Do you see any disparity between the ad-hoc code data-types and the table data-types that just might cause some unnecessary implicit conversions?


No, Char and varchar are fine together and lengths don't cause implicit conversion problems.


I'll have to disagree with that especially on the personal experience level especially where the CHAR data-type is involved. Unfortunately, I can't demonstrate the "personal experience" portion of that because I had them fix it and moved on. I did, however, find an article a couple of months back that had code that demonstrated the problem. Now all I have to do is find the bloody thing. Pinch

I've bookmarked this post. When I find the article and can demonstrate the problem, I'll post back.


Crud. I can't find the article and I can't remember the exact example. I've also tried a couple of shots at it with a test table. Sorry folks, I'll have to retract what I said until I have proof.

And, just to be sure, no... I wasn't confusing this with ORM code passing an NVARCHAR lookup parameter to a lookup on a VARCHAR column. That's a very well known anti-index problem.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search