This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a script to check the total execution count of function or other performance related details of function in SQL Server 2016.
SQL Server 2016 introduced dm_exec_function_stats dm view for checking the stats for user defined function.
Using this, you can check execution count, last execution time, max physical reads, max logical reads and other.
Please check the below script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
SELECT DB_NAME(database_id) AS DatabaseName ,OBJECT_SCHEMA_NAME(OBJECT_ID, database_id) + '.' + OBJECT_NAME(OBJECT_ID, database_id) AS FunctionName ,DEFS.execution_count ,DEFS.total_elapsed_time/DEFS.execution_count AS AvgElapsedTime ,DEFS.last_execution_time ,DEFS.max_worker_time ,DEFS.max_physical_reads ,DEFS.max_logical_reads ,DEFS.max_logical_writes ,T.Text FROM sys.dm_exec_function_stats DEFS CROSS APPLY sys.dm_exec_sql_text(sql_handle) T |
Leave a Reply