Resetting Execution Plans

廉价感情. 提交于 2019-12-11 07:15:58

问题


I am optimizing a query and am worried that SQL Server is caching execution plans so want to wipe them.

How do I do this?


回答1:


You should do this: DBCC FREEPROCCACHE;

I also do this DBCC DROPCLEANBUFFERS;

Use DBCC DROPCLEANBUFFERS to test queries with a cold buffer cache without shutting down and restarting the server.

To drop clean buffers from the buffer pool, first use CHECKPOINT to produce a cold buffer cache. This forces all dirty pages for the current database to be written to disk and cleans the buffers. After you do this, you can issue DBCC DROPCLEANBUFFERS command to remove all buffers from the buffer pool.




回答2:


You'll want to use DBCC FREEPROCCACHE

Removes all elements from the plan cache, removes a specific plan from the plan cache by specifying a plan handle or SQL handle, or removes all cache entries associated with a specified resource pool.



来源:https://stackoverflow.com/questions/8495210/resetting-execution-plans

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!