Most frequent used stored procedures without access to system tables

  • 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

  • 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

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • 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

  • 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


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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