September 12, 2014 at 4:30 am
Hi Experts,
Is there anyway to clear the procedure cache of a single procedure?
TIA
September 12, 2014 at 4:34 am
EXEC sp_recompile 'ProcedureName'
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 12, 2014 at 4:54 am
Thanks a lot Gail.
Developers want to test performance of a particular procedure and requested to run DBCC DROPCLEANBUFFERS & DBCC FLUSHPROCINDB,is it neccessary to ran these. SP_RECOMPILE is enough to test the performance right?
September 12, 2014 at 5:37 am
Tell them that neither are required to test performance of their procedures.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 12, 2014 at 8:32 am
You can also use DBCC FREEPROCCACHE and pass it the plan handle of the plan you want removed from cache.
NOTE: If you don't pass it a plan handle, you remove ALL plans from cache for ALL queries.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 15, 2014 at 1:11 am
GilaMonster (9/12/2014)
Tell them that neither are required to test performance of their procedures.
Thanks Gail..
Can you help me on the other ways to test the performance?
September 15, 2014 at 1:19 am
Grant Fritchey (9/12/2014)
You can also use DBCC FREEPROCCACHE and pass it the plan handle of the plan you want removed from cache.NOTE: If you don't pass it a plan handle, you remove ALL plans from cache for ALL queries.
Thanks Grant.
How can i get the plan handle of a particular procedure?
Found the below query but not able to find for a particular procedure.
SELECT cp.plan_handle, st.[text]
FROM sys.dm_exec_cached_plans AS cp
CROSS APPLY sys.dm_exec_sql_text(plan_handle) AS st
WHERE [text] LIKE N'%/* GetOnlineSearchResultsMonday %';
September 15, 2014 at 6:58 am
If you're looking for a particular procedure name, then those extra spaces in the WHERE criteria are going to mess you up. Remove them and try again.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
September 15, 2014 at 7:10 am
The exec_sql_text DMV has dbid and objectid columns. Use those to identify particular procedures.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 15, 2014 at 7:12 am
True, and while we're on it, there's also the object_id in sys.dm_exec_procedure_stats. So you have a number of ways to get at the plan handle for a given procedure.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply