Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Profiling how should I go about it?

So I have used SQL Profiler before and I know how I can view what my LINQ queries are doing behind the scenes. Now, we are in the process of identifying queries that may take more time and need to be optimized or have some indexing.

So, now when I view my LINQ queries in the profiler running it side by side there is lot of other data and queries that I dont care. Is there anyway the profiler or some other tools could sort the queries in the order of the largest time....so that I will work on optimizing it. I want to run my application and then see somehow in the profiler the worst queries of the lot.

Can anyone guide or direct me towards something that is more useful trying to do profiling with sql server 2005. Also any ideas or suggestions or best ways about going about profiling are welcome. Thanks.

like image 926
Vishal Avatar asked Oct 27 '10 18:10

Vishal


People also ask

Is SQL Server Profiler the same as SQL Server?

SQL profiler is a GUI tool in Microsoft SQL Server relational database management system that allows us to monitor, analyze, troubleshoot, re-create, and trace the problems of SQL databases and their environments. It was first introduced in the SQL Server 2000 version.

Is SQL Server Profiler deprecated?

SqlServer. Management. Trace namespace that contains the Microsoft SQL Server Trace and Replay objects will also be deprecated. Note that SQL Server Profiler for the Analysis Services workloads is not being deprecated, and will continue to be supported.

Does SQL Server Profiler affect performance?

Yes, SQL Server Profiler does affect performance. When you trace using the GUI, all events are synchronously processed and filtered, so factors such as server load, network latency, which events you collect, and even where the collected events are stored, all contribute to overhead.


1 Answers

Here is a query on a DMV that will list queries with some details on CPU time. Once you pinpoint the query run it with Include Actual Execution Plan set on to see the query flow and where you might need indexed.

select  
    highest_cpu_queries.plan_handle,  
    highest_cpu_queries.total_worker_time, 
    q.[text] 
from  
    (select top 50  
        qs.plan_handle,  
        qs.total_worker_time 
    from  
        sys.dm_exec_query_stats qs 
    order by qs.total_worker_time desc) as highest_cpu_queries 
    cross apply sys.dm_exec_sql_text(plan_handle) as q 
order by highest_cpu_queries.total_worker_time desc

Here is a good article on finding performance problems.

like image 111
Dustin Laine Avatar answered Sep 22 '22 06:09

Dustin Laine