Saturday, January 5, 2013
TSQL Get Queries with Maximum cost
--TSQL Get Queries with Maximum cost
select highest_cpu_queries.total_worker_time, q.dbid, q.objectid, q.number, q.encrypted, q.[text],highest_cpu_queries.*
from
(
select top 50 qs.*
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
--REINDEX TABLE TO OPTIMIZE QUERIES
DBCC DBREINDEX(TBL_Product, '', 80)
--OR
DBCC DBREINDEX (TBL_Product)
--AND CONSIDER WHICH FIELDS NEED NON CLUSTERED INDEX IN YOUR DB
SELECT * FROM SYS.dm_db_missing_index_details
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment