Check index fragmentation:
SELECT DB_NAME() AS DBName ,OBJECT_NAME(ps.object_id) AS TableName ,i.name AS IndexName ,ips.index_type_desc ,ips.avg_fragmentation_in_percent FROM sys.dm_db_partition_stats ps INNER JOIN sys.indexes i ON ps.object_id = i.object_id AND ps.index_id = i.index_id CROSS APPLY sys.dm_db_index_physical_stats(DB_ID(), ps.object_id, ps.index_id, null, 'LIMITED') ips ORDER BY ps.object_id, ps.index_id
List slowest sql executions with QueryPlans (if you save them as .sqlplan you can easily open it in Management Studio)
SELECT qs.max_worker_time, qs.max_elapsed_time, st.text, qp.query_plan, qs.* FROM ( SELECT TOP 50 * FROM sys.dm_exec_query_stats ORDER BY total_worker_time DESC ) AS qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS qp WHERE qs.max_worker_time > 300 OR qs.max_elapsed_time > 300 ORDER BY qs.max_elapsed_time DESC
Next query:
SELECT ...
No comments:
Post a Comment