SQL Server 2000: How can I tell how many plans a stored procedure has cached? -
Sometimes when diagnosing problems with our SQL Server 2000 database, it can be useful to know that a stored procedure is using a bad plan or at the time when I'm having problems, there is a problem with a good plan. I am wondering if there is a query or command that can tell me how much current execution scheme caches for a particular stored procedure. Are.
You can ask the cache in several different ways, either viewing its content, Or you can see some relevant statistics.
Some order routes to help you:
Select from syscacheobjects - Displays the contents of the process - Cache DBCC Process for all databases - shows some common cache stats DBCC CashState - shows usage statistics for cache, things like hit ratio
If you only need to clear the cache for a database, then you can use it:
DBCC flushhprocia DB (@dbid) - this is an int, its name is not - you can get the insent
from the Scinabetbase or DBID () function: above the line For 2000, who asked that question. However, for anyone using SQL Server 2005 , this is slightly different from above:
select from A useful query to show plans in 2005:
Select cachebizip, objtype, usecounts, refcounts, join sys.dm_exec_cached_plans at sys.dm_exec_query_stats Apply p.plan_handle = s.plan_handle cross sys.dm_exec_sql_text (s.sql_handle)