Stored Procedures Performance

  • Comments posted to this topic are about the item Stored Procedures Performance

  • This is a good script.

    One suggested addition would be a 'schemaname' column. When I'm unit testing in Development, I often times have a different version of the stored procedure contained under different schema(s), so I can compare their runtime side by side.

    select

    ...

    os.schemaname,

    ...

    join (select object_id id, schema_name(schema_id)schemaname

    from sys.objects) os on os.id = object_id

    ...

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • adnan.korkmaz (5/5/2012)


    Comments posted to this topic are about the item <A HREF="/scripts/Stored+Procedures/90129/">Stored Procedures Performance</A>

    Good script..

    This will only work for SQL server 2008 and plus.

    ______________________________________________________________________________________________________________________________________________________________________________________
    HTH !
    Kin
    MCTS : 2005, 2008
    Active SQL Server Community Contributor 🙂

  • Good One ....

  • i run it on SQLServer2008 R2, why received the msg:

    Msg 208, Level 16, State 1, Line 2

    Invalid object name 'sys.dm_exec_procedure_stats'.

  • Nice script.

    If parallel plan is used in the procedure for any query(ies) then the cpu time doesnt reflect actual cpu time but of the thread which started the proc execution. Thus it sometimes is misleading...

    http://www.sqlservercentral.com/Forums/Topic1304371-391-1.aspx

    GulliMeel

    Finding top n Worst Performing queries[/url]
    Improve the performance of Merge Join(special case)
    How to Post Performance Problem -Gail Shaw[/url]

  • Hi @caoxp930,

    Two possibilities that I can think of:

    1) You might have ran the query on a SQL 2005 server, via SQL 2008 interface. The sys.dm_exec_procedure_stats doesn't exist on SQL 2005.

    2) You don't have VIEW SERVER STATE permission on the server you are running the query.

  • Eric M Russell (5/7/2012)


    This is a good script.

    One suggested addition would be a 'schemaname' column. When I'm unit testing in Development, I often times have a different version of the stored procedure contained under different schema(s), so I can compare their runtime side by side.

    select

    ...

    os.schemaname,

    ...

    join (select object_id id, schema_name(schema_id)schemaname

    from sys.objects) os on os.id = object_id

    ...

    Good suggestion but no need to join unnecessarily - use OBJECT_SCHEMA_NAME([object_id])

    😉

    gsc_dba

  • Very nice. 🙂

  • Use extreme prejudice when and where you run DBCC FREEPROCCACHE! SQL Books Online sums this up quite nicely:

    Use DBCC FREEPROCCACHE to clear the plan cache carefully. Freeing the plan cache causes, for example, a stored procedure to be recompiled instead of reused from the cache. This can cause a sudden, temporary decrease in query performance.

  • This is a pretty cool script. Thanks.

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply