How do I force SQL Server to use an old execution plan?

How do I force SQL Server to use an old execution plan?

Forcing Execution Plan

  1. Get the OLD execution plan from old server. You can get this from SSMS or DMV’s or Profiler.
  2. At this point you have 1.) Query text that needs to be tuned 2.)
  3. To verify weather the plan guide is getting picked up, you can 1.) either run profiler with “Plan guide successful” event or 2.)

How do I force a query plan in SQL Server?

Actual Execution Plans in SQL Server Management Studio

  1. Hit “Ctrl + M” and it will generate the actual execution plan after the query has been executed successfully.
  2. Right-click on the query window and select “Display Actual Execution Plan” from the context menu.

What is cached execution plan in SQL Server?

Every query requires a query plan before it is actually executed. This query plan is stored in SQL Server query plan cache. This way when that query is run again, SQL Server doesn’t need to create another query plan; rather it uses the cached query plan which improved database performance.

Where does the cache plan go in SQL Server?

If a plan with same hash value exists, that plan is executed. However, if a plan with the newly calculated hash value doesn’t exist, a new query plan is generated and stored in the cache plan.

Is there way to temporarily disable execution plan caching in SQL Server?

While query execution plan caching is great in production it is interfering with our debugging efforts. Is there are way to temporary disable execution plan caching in SQL Server (any further) so I can get a reliable & true indicator of the parse & compile time on SQL each time I run the query batch?

What is DM _ exec _ cached _ plans in SQL Server?

The first dm_exec_cached_plans is a dynamic management view while the remaining two are dynamic management functions. Let us use these functions and views to see what is in the SQL Server cached query plan. Execute the following query on your SSMS (SQL Server Management Studio):

How often does a query plan stay in the cache?

The duration that a query plan stays in the plan cache depends upon how often a query is executed. Query plans that are used more often, stay in the query plan cache for longer durations, and vice-versa.