views:

3512

answers:

4

Hi folks

The activity monitor in sql2k8 allows us to see the most expensive queries. Ok, that's kewl, but is there a way I can log this info or get this info via query analyser? I don't really want to have the Sql Management console open and me looking at the activity monitor dashboard.

I want to figure out which queries are poorly written/schema is poorly designed, etc.

Thanks heaps for any help!

+2  A: 

Would the SQL Server Profiler do what you need? I haven't used 2008 yet so I don't know if the tool is still in there but if it is I believe you can set up a trace to log queries that meet specific criteria (such as those that execute and drive CPU up above a certain threshold).

We've used this on our project and it did a pretty good job of helping us troubleshoot poorly executing queries (though don't leave it on full time, rely on the general Windows Performance Counters for performance health tracking).

cfeduke
hmm.. i've used the profiler heaps, but that doesn't summarise information. it's a line per query type of thing.
Pure.Krome
+21  A: 
Mitch Wheat
cheers mitch! sounds a bit more complex that i thought was required, but i'll most definitely give it a go :) cheers!
Pure.Krome
How did you go with your profiler analysis?
Mitch Wheat
Been flat out - i'm expecting to get a chance towards the end of nov .. and then i'll mark the question or ask more q's.
Pure.Krome
+3  A: 

A late answer...

Use DMVs to find out. Easier then profiler...

gbn
Thanks Glenn! Nice answer also :)
Pure.Krome
+1  A: 

I had never heard of this tool before, but Microsoft provides a set of reports that do a fantastic job of giving you exactly this - including slowest queries. Check out their Performance Dashboard Reports.

Not sure if they're SQL 2008-compatible, but worth checking out.

tlianza