Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Mysterious deadlocks on a heap table Expand / Collapse
Author
Message
Posted Saturday, July 5, 2014 1:04 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 8:56 PM
Points: 2,550, Visits: 7,170
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.
Post #1589542
Posted Saturday, July 5, 2014 2:13 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 1:17 PM
Points: 4,474, Visits: 6,407
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.


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
Post #1589553
Posted Saturday, July 5, 2014 2:43 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 8:56 PM
Points: 2,550, Visits: 7,170
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.


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 lag
Post #1589561
Posted Saturday, July 5, 2014 3:41 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 6:05 PM
Points: 35,832, Visits: 32,505
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.

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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1589567
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse