|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 8:56 AM
Points: 22,
Visits: 140
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, January 29, 2013 4:08 AM
Points: 1,140,
Visits: 306
|
|
| Any cheap and cheerful mechanisms for testing this issue in a non-production environment are most welcome. Brute force will reveal issues that really need sorting.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 8:06 AM
Points: 900,
Visits: 654
|
|
nice article can you also give us the solutions to make it resistent
Abhijit - http://abhijitmore.wordpress.com
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Thursday, February 14, 2013 12:01 PM
Points: 743,
Visits: 900
|
|
A very interesting and thought provoking article. Thank you!
On actually making your application more resistant to locking, the careful use of the "with (nolock)" query hint can improve performance on a server with a lot of locking tremendously.
Of course, I cannot overemphasize the fact that developers should be careful and thoughtful in using it since it risks dirty reads. But there are times when a dirty read is acceptable, such as when you can known with great confidence that the records you are selecting are not being modified at that moment or when all you really care about is rough approximations of aggregate values. In those cases, it can be tremendously helpful.
--- Timothy A Wiseman SQL Blog: http://timothyawiseman.wordpress.com/
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 8:56 AM
Points: 22,
Visits: 140
|
|
timothyawiseman (3/10/2010) Of course, I cannot overemphasize the fact that developers should be careful and thoughtful in using it since it risks dirty reads.
Agreed. It's easy for the scope of an article like this to expand exponentially. Each of the ways that I mentioned to deal with resource contention, etc, could have been their own article, and it would be easy to spend hours (or at least lots of minutes) talking about each one.
Every one of the things I mentioned carries some level of risk (taking database interaction off the UI thread, playing with isolation levels, query hints, etc), but then again, we live in a pretty risky world
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: 2 days ago @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 5:52 AM
Points: 165,
Visits: 1,022
|
|
| Perhaps you should note in your article that the first script that you posted, the one that shows "TimesAccessed", only shows the data since the last restart of the SQL Server instance.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 8:56 AM
Points: 22,
Visits: 140
|
|
GDI Lord (3/10/2010) Perhaps you should note in your article that the first script that you posted, the one that shows "TimesAccessed", only shows the data since the last restart of the SQL Server instance.
Indeed. Good point GDI Lord.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 8:17 AM
Points: 334,
Visits: 280
|
|
Hi Tim, I am pretty sure that this statement is not accomplishing what you intended.
exec('USE ' + @YourDatabaseName)
When Exec is executed the database context is changed, but only for the statement(s) in the parenthsis. When Exex completes the database context returns to its previous setting. You can see that behavior with the following test script.
Use AdventureWorks Declare @myDatabase varChar(255) Set @myDatabase = 'Northwind' Exec ('Use ' + @myDatabase + '; Select db_Name(); Select [name] from sys.objects where type = ''U'' ') Select db_Name() Select [name] from sys.objects where type = 'U'
You will see that the database context returns to AdventureWorks after the conclusion of the Exec script.
I am still looking for a reasonable methog to dynamically change the database context so if you find one please post it :)
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, April 09, 2013 11:45 AM
Points: 26,
Visits: 156
|
|
WHERE ius.database_id = DB_ID() AND DB_NAME(ius.database_id)=@YourDatabaseName
The first condition is sufficient right? ius.database_id = DB_ID() should uniquely identify the correct database without the need for checking the db name as well.
Or am I missing something?
Thanks!
|
|
|
|