Troubleshooting and Optimizing Queries with SQL Azure

In you want to troubleshoot queries performance in SQL Azure, the following paper provides guidelines on the Dynamic Management Views that are available in SQL Azure, and how they can be used for troubleshooting purposes.

 

http://www.microsoft.com/downloads/details.aspx?FamilyID=0CEB6317-0E52-4A25-8AF2-2702C9C21358&displayLang=en

 

The following are some examples taken from the paper:

 

-- Identity excessive recompiles
select top 25
sql_text.text,
sql_handle,
plan_generation_num,
execution_count,
dbid,
objectid
from
sys.dm_exec_query_stats a
cross apply sys.dm_exec_sql_text(sql_handle) as sql_text
where
plan_generation_num >1
order by plan_generation_num desc



-- Inefficient query plans:
select
highest_cpu_queries.plan_handle,
highest_cpu_queries.total_worker_time,
q.dbid,
q.objectid,
q.number,
q.encrypted,
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



-- I/O Bottlenecks
select top 25
(total_logical_reads/execution_count) as avg_logical_reads,
(total_logical_writes/execution_count) as avg_logical_writes,
(total_physical_reads/execution_count) as avg_phys_reads,
Execution_count,
statement_start_offset as stmt_start_offset,
sql_handle,
plan_handle
from sys.dm_exec_query_stats
order by
(total_logical_reads + total_logical_writes) Desc




Regards,

Ing. Eduardo Castro Martínez, PhD – Microsoft SQL Server MVP

 image image image image



http://mswindowscr.org

http://comunidadwindows.org

Costa Rica

Technorati Tags: SQL Server

LiveJournal Tags: SQL Server

del.icio.us Tags: SQL Server

http://ecastrom.blogspot.com

http://ecastrom.wordpress.com

http://ecastrom.spaces.live.com

http://universosql.blogspot.com

http://todosobresql.blogspot.com

http://todosobresqlserver.wordpress.com

http://mswindowscr.org/blogs/sql/default.aspx

http://citicr.org/blogs/noticias/default.aspx

http://sqlserverpedia.blogspot.com/

Note: Cross posted from Eduardo Castro.

Permalink

Comments

Popular posts from this blog

Desempeño de SQL Server 2008 R2 y Max Worker Threads

Cómo identificar consultas más pesadas en SQL Server

SQL Server La longitud de los datos LOB (2200100) que se van a replicar excede el máximo configurado 65536.