SQL Clone
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
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38281 Visits: 19417
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
SSC-Dedicated
SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)SSC-Dedicated (30K reputation)

Group: General Forum Members
Points: 30319 Visits: 8666
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 on googles mail service
Eirikur Eiriksson
Eirikur Eiriksson
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38281 Visits: 19417
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 Guru
SSC Guru (202K reputation)SSC Guru (202K reputation)SSC Guru (202K reputation)SSC Guru (202K reputation)SSC Guru (202K reputation)SSC Guru (202K reputation)SSC Guru (202K reputation)SSC Guru (202K reputation)

Group: General Forum Members
Points: 202761 Visits: 41943
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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

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