I have been able to run the following code to gather statistics of adaption of SQL Server 2016+ functions, however these counters reset on system reboots.
SELECT
DB_NAME(fs.database_id) DatabaseName,
OBJECT_NAME(object_id, database_id) FunctionName,
fs.cached_time, fs.last_execution_time, fs.total_elapsed_time,
fs.total_worker_time, fs.total_logical_reads, fs.total_physical_reads,
fs.total_elapsed_time/fs.execution_count AS [avg_elapsed_time],
fs.last_elapsed_time, fs.execution_count
FROM
sys.dm_exec_function_stats AS fs
WHERE
1=1
AND NOT DB_NAME(fs.database_id) IN ('master','msdb')
ORDER BY [total_worker_time] DESC
Is there a location in SQL Server that will give me the over all statistics over the lifetime of the instance that I haven't yet found?
question from:https://stackoverflow.com/questions/65672121/sql-server-count-of-function-usages