November 10, 2013 at 6:02 am
Is there a way to determine the most frequently used stored procedures in a given database if you do not have access to system tables? In all of the searches I have done the solution uses the system tables. Unfortunately, I do not have access to those. Thank you
November 10, 2013 at 8:25 am
From:
http://glennberrysqlperformance.spaces.live.com/default.aspx
Try this
SELECT TOP 100 qt.text AS 'SP Name', qs.execution_count AS 'Execution Count',
qs.execution_count/DATEDIFF(Second, qs.creation_time, GetDate()) AS 'Calls/Second',
qs.total_worker_time/qs.execution_count AS 'AvgWorkerTime',
qs.total_worker_time AS 'TotalWorkerTime',
qs.total_elapsed_time/qs.execution_count AS 'AvgElapsedTime',
qs.max_logical_reads, qs.max_logical_writes, qs.total_physical_reads,
DATEDIFF(Minute, qs.creation_time, GetDate()) AS 'Age in Cache'
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
WHERE qt.dbid = db_id() -- Filter by current database
ORDER BY qs.execution_count DESC
November 10, 2013 at 8:52 am
Ron - thank you for replying so soon. However, because I do not have access to the system tables the query does not work for me. Here is the error message I receive when I try to run it.
Msg 297, Level 16, State 1, Line 1
The user does not have permission to perform this action.
Is there a way around not using system tables? Thank you
November 10, 2013 at 12:19 pm
bhutchin (11/10/2013)
Ron - thank you for replying so soon. However, because I do not have access to the system tables the query does not work for me. Here is the error message I receive when I try to run it.Msg 297, Level 16, State 1, Line 1
The user does not have permission to perform this action.
Is there a way around not using system tables? Thank you
Yes there is. If you've been tasked with doing such a thing, you well know that it's near impossible to do without the correct privs. You need to petition for and get the right privs to do this or have the DBAs do this for you.
The alternative is to get each stored proc to do it's own logging. With a little imagination and forethough, that's not as difficult to do as you might think.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 11, 2013 at 12:02 am
Jeff Moden (11/10/2013)
The alternative is to get each stored proc to do it's own logging. With a little imagination and forethough, that's not as difficult to do as you might think.
This. It'll be more reliable than using the DMVs too.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 11, 2013 at 6:08 am
Thank you all very much for your replies. You have confirmed for me what I had suspected. I need to have the privileges to the system tables if I am the one that is to find the data. We can consider this topic asked and answered.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply