Link to home
Start Free TrialLog in
Avatar of kevinmkr1
kevinmkr1

asked on

What is the best way to track down/eliminate/prevent Deadlock Transaction issues with CF7 and SQL Server 2005?

While I consider myself fairly experienced with CF and SQL syntax, I am not terribly well-versed in SQL Server.  Therefore, I do not (have not) used stored procedures or triggers, etc.  I would prefer not to, at this point, until I have time to fully learn SQL Server.

My current project involves hospital patients (stored in one table) and their treatment events (stored in another table).  The treatment table contains 56 columns of varying type and, since it contains every unique patient treatment event, contains hundreds of thousands of records.  The table can be accessed from dozens of pages and reports and can be updated in a half-dozen other places.
Long story short, it's a big table that has multiple avenues of entry and, as a result, is constantly being viewed and altered by users.

Slowly, over time (years), I've been noticing more and more of the "Transaction (Process ID XX) was deadlocked on lock resources with another process and has been chosen as the deadlock victim." errors and they all seem to involve using a SELECT on the treatment table.
I've tried to consider and repair most "best practice" SQL issues (there are no "SELECT * FROM", for example) but it has not helped.

I've read in many places that I should consider using "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED" before my SELECTS (and, presumably, my INSERTS and UPDATES?).  I'm not sure if this is the best solution to the issue or if it simply glosses over a bigger issue.

So, considering the following:

1) Pure SQL only (no triggers or stored procedures)
2) Large (and growing) table (indexed by SQL Query Analyzer)
3) Can be accessed from many places through the system
4) We have several installations -- all meet a minimum system requirement of CF7 and MS SQL 2005.

What would be the best solution or way to attack this?
SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevinmkr1
kevinmkr1

ASKER

That is something that I had considered (shrinking that table) but was concerned that it would end up being a whole lot of work recoding with the potential that it wouldn't fix the issue.  The reason being that 100% of the accesses includes the "DueDate", either for creating calendars, or running reports ("Who's coming in this week?", "Which patients are receiving this drug this month?", "Which patients are coming in today for Dr. Smith?").  So, while I *could* break out many of the lesser used columns (at a great time-expense), every request would be hitting that table, regardless.

So, I guess I should ask you -- would cutting the table down to 50% (or 25%) of its width, without reducing the quantity of accesses, speed the transaction execution time enough to make the effort worthwhile, based on your experience?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's a really great point -- I'm sure you're right (regarding the CF vs SQL tagging).  My thought process was, I am not prepared for any extremely heavy SQL at this point and so an answer like, "move all of your SQL inserts to Stored Procedures and then set a trigger here...etc" would be far too much for me at this point.  I was rather hoping somebody with CF experience would have some magical solution.  Considering that I've been coding for 10 years in CF and this is my first time posting on Experts-Exchange, I should have realized that I would not be receiving a simple answer -- otherwise I would have been able to find it by my traditional avenues.  :)

Do you have any experience with 'READ_COMMITTED_SNAPSHOT'?  That came up a few times as a solution, as well.

As for finishing out this question, I'm not sure what the common Experts Exchange protocol is, but I would like to leave this open for another few days just in case a true dba shows up.  I intend to award you partial (or complete) points, in all cases.  I would even take your recommendation as to how to distribute them (if you do not end up receiving them all).

Thanks for your assistance.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It doesn't look like I'm going to get any other action here so I think I'll close this up.

Thanks again for the links and advice.  It should get me well on my way towards diagnosing these issues.
As this doesn't seem to be a "one size fits all" situation, I'm not sure how the answer provided could have been improved upon.
It might be worth it to open a new question - only in the MS SQL-type zones - about the READ_COMMITTED_SNAPSHOT issue.  As for some opinions/experiences of people who've used it.  Then at least you'll have a better sense of how viable an option it is (or isn't) for your particular setup.  

Best of Luck
> As for some

Correction:  ASK for some ..