SQL Server 2005 如何清除查询执行计划 [英] SQL Server 2005 How Do You Clear Out a Query Execution Plan

查看:54
本文介绍了SQL Server 2005 如何清除查询执行计划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

各位程序员好.我有一个 SQL Server 2005 查询,第一次处理需要很长时间.第一次运行后,查询的运行速度要快得多.它从一分钟到一秒.

Hello fellow programmers. I have a SQL Server 2005 query that is taking a long time to process the first time through. After the first run the query works much faster. It goes from one minute to one second.

我知道 SQL Server 正在缓存一个执行计划(这是正确的术语吗?).我想要做的是清除这个执行计划,以便我可以更好地复制问题.我正在尝试调整查询.

I know that SQL Server is caching an execution plan (is that the right term? ). What I want to do is clear out this execution plan so that I can replicate the issue better. I'm trying to tune the query.

有谁知道这是否可能以及如何做到?

Does anyone know if this possible and how to do it?

提前致谢

推荐答案

如果你想清除它,那么:

If you want to clear it then:

DBCC FreeProcCache
DBCC DropCleanbuffers

如果只想强制每次查询重新编译,那么在查询的末尾添加查询提示:

If you just want to force a query recompilation each time, then add a query hint to the end of the query:

OPTION (RECOMPILE)

这篇关于SQL Server 2005 如何清除查询执行计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆