Select PS.total_logical_reads/NullIf( DateDiff(Minute,PS.cached_time ,GetDate()),0) N,
Coalesce(DB_Name(PS.database_ id),DB_Name(PSh.dbid),DB_Name( PSph.dbid))
DBName,
Object_Schema_Name(Coalesce(PS .object_id,PSh.objectid,PSph.o bjectid),Coalesce(PS.database_ id,PSh.dbid,PSph.dbid))
SchemaName,
Coalesce(Object_Name(PS.object _id,PS.database_id),Object_ Name(PSh.objectid,PSh.dbid),Ob ject_Name(PSph.objectid,PSph.d bid))
ObjectName,
PS.*,
PSh.text,
PSph.query_plan
From (Select Object_Name(object_id), *
From sys.dm_exec_procedure_stats (NoLock)
Where database_id=DB_ID(' DatabaseName')
And Object_Schema_Name(object_id)= 'SchemaName'
And Object_Name(object_id)=' SpName'
Order By total_logical_reads/NullIf(Dat eDiff(Minute,cached_time,GetDa te()),0) Desc) PS
Outer Apply sys.dm_exec_sql_text(PS.sql_ handle) PSh
Outer Apply sys.dm_exec_query_plan(PS.plan _handle) PSph;
No comments:
Post a Comment