SQL Server 2000:如何知道存储过程已缓存了多少个计划?
有时,在诊断 SQL Server 2000 数据库的问题时,了解存储过程正在使用错误的计划或在遇到问题时难以想出一个好的计划可能会有所帮助。 我想知道是否可以运行一个查询或命令来告诉我当前为特定存储过程缓存了多少个执行计划。
Sometimes when diagnosing issues with our SQL Server 2000 database it might be helpful to know that a stored procedure is using a bad plan or is having trouble coming up with a good plan at the time I'm running into problems. I'm wondering if there is a query or command I can run to tell me how many execution plans are cached currently for a particular stored procedure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过多种不同的方式查询缓存,可以查看其内容,也可以查看一些相关的统计信息。
有几个命令可以帮助您:
如果您只需要清除一个数据库的缓存,您可以使用:
编辑:上面的行是 2000,这就是问题所问的内容。 然而,对于任何使用SQL Server 2005的访问者来说,这与上面的安排略有不同:
用于显示 2005 年计划的有用查询:
You can query the cache in a number of different ways, either looking at its contents, or looking at some related statistics.
A couple of commands to help you along your way:
If you need to clear the cache for just one database, you can use:
Edit: above the line is for 2000, which is what the question asked. However, for anyone visiting who's using SQL Server 2005, it's a slightly different arrangement to the above:
A useful query for showing plans in 2005: