Sql-server – seeing high execution counts for the system stored procedure sys.sp_columns_managed

sql server

We are seeing high wait times during business hours on one of our databases. Looking at SolarWinds I am finding that the system stored procedure 'sys.sp_columns_managed' is being executed more than 300,000 times per hour (according to SolarWinds). Has anyone else ever experienced this? Does anyone know what can be done to stop this? Or, am I not seeing things correctly in SolarWinds?

Best Answer

This script below shows you the execution count of the stored procedures that are currently in your plan cache.

set transaction isolation level read uncommitted

SELECT DB_NAME(st.dbid) DBName
      ,OBJECT_SCHEMA_NAME(st.objectid,dbid) SchemaName
      ,OBJECT_NAME(st.objectid,dbid) StoredProcedure
      ,max(cp.usecounts) Execution_count
 FROM sys.dm_exec_cached_plans cp
         CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) st
 where DB_NAME(st.dbid) is not null and cp.objtype = 'proc'
   group by cp.plan_handle, DB_NAME(st.dbid),
            OBJECT_SCHEMA_NAME(objectid,st.dbid), 
   OBJECT_NAME(objectid,st.dbid) 
 order by max(cp.usecounts) desc

That would be an starting point, if you could see the procedure there and from which database it is fired.

Then have a look who and what is using that particular database\calling that procedure.

here you can find the code of the sys.sp_columns_managed stored procedure.