|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 12:48 PM
Points: 13,381,
Visits: 25,169
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, October 08, 2012 8:42 AM
Points: 1,
Visits: 7
|
|
from the name of the table, I guess there is a considerable amount of records in it. It looks like it, unneccessarily, computes the dateadd function for each row.
you might store the value in a variable
declare @yesterday smalldatetime = dateadd("d", -1, getdate())
and use it like
... and date > @yesterday
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 12:48 PM
Points: 13,381,
Visits: 25,169
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, January 07, 2013 12:59 PM
Points: 2,
Visits: 13
|
|
"The measured average is only .4 at peaks around that time, so we're not looking at multiple processes fighting over the processor. That means one event is causing the problem."
How did you know it was only one event? Or that it wasn't multiple processes?
Thanks.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 2:17 PM
Points: 24,
Visits: 179
|
|
| Where are those analysis pages coming from? Is it a feature in SQL activity monitor? If so, please advice the proper steps to do what you show. If you are using a tool to build sll that, let me know what u use.
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 3:15 PM
Points: 85,
Visits: 607
|
|
tolga.kurkcuoglu (9/13/2012) from the name of the table, I guess there is a considerable amount of records in it. It looks like it, unneccessarily, computes the dateadd function for each row.
you might store the value in a variable
declare @yesterday smalldatetime = dateadd("d", -1, getdate())
and use it like
... and date > @yesterday
I doubt that that will make any difference. I'd be very surprised if the engine calls the dateadd function more than once. In the optimization phase it will do what you suggest. It just won't tell you about it.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 6:42 AM
Points: 1,766,
Visits: 465
|
|
Check the stats on the table. Look at execution plan for bootlenecks/scans etc Veryify order of Where parameters works to effectively Check the indexes for existence and fragmentation. Definitely pre calc the date comparision. If stored procedure then after verifying stats are up to date then I'd do an sp_recompile on the sProc
Much to learn, teach me Yoda
Tom in Sacramento
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 12:48 PM
Points: 13,381,
Visits: 25,169
|
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Monday, April 15, 2013 11:42 PM
Points: 424,
Visits: 55
|
|
|
|
|