I've been running the following script to capture plan usage stats.
SELECT DB_NAME(st.dbid) DBName
,OBJECT_SCHEMA_NAME(st.objectid, dbid) SchemaName
,OBJECT_NAME(st.objectid, dbid) StoredProcedure
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
In my results I see the same stored procedure using 2 different plans, I'm curious as to why. Initially I figured the plan was updated and now it's using the new but I see execution counts increasing for both.
I'm not trying to solve any issues here i'm running this script to determine what sprocs are still in use, mostly just curious if anyone knows why a sproc would use 2 different plans?