如何让 SQL Server 知道不要在查询中使用缓存? [英] How to let SQL Server know not to use Cache in Queries?
问题描述
只是一个普遍的问题:
是否有查询/命令可以传递给 SQL Server 以在执行特定查询时不使用缓存?
Is there a query/command I can pass to SQL Server not to use cache when executing a particularly query?
我正在寻找可以设置的查询/命令,而不是配置设置.没有必要这样做吗?
I am looking for a query/command that I can set rather than a configuration setting. Is there no need to do this?
推荐答案
DBCC FREEPROCCACHE
将删除所有缓存的程序执行计划.这将导致重新编译所有后续过程调用.
Will remove all cached procedures execution plans. This would cause all subsequent procedure calls to be recompiled.
将 WITH RECOMPILE
添加到过程定义会导致该过程在每次调用时都被重新编译.
Adding WITH RECOMPILE
to a procedure definition would cause the procedure to be recompiled every time it was called.
我不相信(在 SQL 2005 或更早版本中)有任何方法可以清除单个过程执行计划的过程缓存,而且我怀疑您是否可以在 2008 年做到这一点.
I do not believe that (in SQL 2005 or earlier) there is any way to clear the procedrue cache of a single procedures execution plan, and I'd doubt you could do it in 2008 either.
这篇关于如何让 SQL Server 知道不要在查询中使用缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!