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

SSC Clinic: Finding the rogue query Expand / Collapse
Author
Message
Posted Thursday, September 13, 2012 12:03 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:07 AM
Points: 14,034, Visits: 28,406
Comments posted to this topic are about the item SSC Clinic: Finding the rogue query

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server Query Performance Tuning
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1358350
Posted Thursday, September 13, 2012 2:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, October 8, 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
Post #1358393
Posted Thursday, September 13, 2012 6:03 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:07 AM
Points: 14,034, Visits: 28,406
Good suggestion. I haven't started tuning the query yet, but that's absolutely one of the changes I'll make. Thanks.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server Query Performance Tuning
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1358496
Posted Thursday, September 13, 2012 6:45 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, September 11, 2013 8:54 AM
Points: 2, Visits: 20
"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.
Post #1358516
Posted Thursday, September 13, 2012 8:36 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 9:03 AM
Points: 24, Visits: 257
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.
Post #1358614
Posted Thursday, September 13, 2012 9:20 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Saturday, May 31, 2014 10:37 PM
Points: 85, Visits: 625
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.
Post #1358653
Posted Thursday, September 13, 2012 10:46 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, November 13, 2014 10:19 AM
Points: 2,340, Visits: 599
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/
Post #1358713
Posted Friday, September 14, 2012 6:02 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:07 AM
Points: 14,034, Visits: 28,406
OceanDeep (9/13/2012)
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.


It's all from Red Gate SQL Monitor. You can see it in action against SQL Server Central here at monitor.red-gate.com


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server Query Performance Tuning
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1359199
Posted Tuesday, December 25, 2012 8:41 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, April 15, 2013 11:42 PM
Points: 424, Visits: 55
Good article.
Post #1400076
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse