SQL Server 2000 - 我的查询突然运行缓慢
我的数据库查询一直运行得非常快,直到最近变得非常慢。 除了正常的数据增长之外,数据库没有发生任何变化。
我注意到数据库统计信息“从未”更新过。
有没有一种简单的方法可以更新整个数据库中的这些统计信息,以便我可以查看这是否是问题所在?
我使用的是 SQL Server 2000 Sp4。
My database query has been running very fast until it changed to very slow recently. No changed have occurred in the database apart from normal data growth.
I have noticed that the database statistics have "never" been updated.
Is there an easy way that I can update these statistics across my entire database so I can see if that is the problem?
I am using SQL Server 2000 Sp4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用它
,这将更新数据库中所有表的统计信息。 您还应该查看索引并重建/碎片整理作为必要的
Raj
You can use this
This will update stats on all the tables in the DB. You should also look at indexes and rebuild / defrag as nexessary
Raj
尝试此处
这应该会加快您的索引速度和密钥分发。 重新分析表统计信息可以优化 SQL Server 对查询的索引选择,尤其是对于大型数据集
Try here
This should speed up your indices and key distribution. Re-analyzing table statistics optimises SQL Server's choice of index for queries, especially for large datasets
一定要为自己制定一个每周自动运行的任务来更新数据库的统计数据。
Definitely make yourself a weekly task that runs automatically to update the database's statistics.
正常数据增长足以作为理由,证明几乎任何未优化查询的减速都是合理的。
与数据库大小相关的可扩展性问题在数据量增长之前不会显现出来。
发布您的查询+粗略数据量,我们将帮助您了解情况。
Normal Data Growth is good enough as a reson to justify a slowdown of pretty much any not optimized query.
Scalability issues related db size won't manifest till the data volume grows.
Post your query + rough data volume and we'll help you to see what's what.
我们在 MSSQL 2005 中也遇到过非常类似的问题,查询运行速度突然变慢。
我们是这样解决这个问题的:我们为查询中的每个 select 语句添加 (nolock)。 例如:
请注意,nolock 也应该添加到嵌套 select 语句以及连接中。 这里有一篇文章提供了有关使用 nolock 时如何提高性能的更多详细信息。 http://www.mollerus.net/tom/blog/2008/ 03/using_mssqls_nolock_for_faster_queries.html
显然,不要忘记保留原始查询的备份。 请尝试一下并告诉我。
We've had a very similar problem with MSSQL 2005 and suddenly slow running queries.
Here's how we solved it: we added (nolock) for every select statement in the query. For example:
Note that nolock should also be added to nested select statements, as well as joins. Here's an article that gives more details about how performance is increased when using nolock. http://www.mollerus.net/tom/blog/2008/03/using_mssqls_nolock_for_faster_queries.html
Don't forget to keep a backup of your original query obviously. Please give it a try and let me know.