如何调整查询

发布于 2024-09-15 23:21:25 字数 104 浏览 4 评论 0原文

我有一个运行缓慢的查询。我知道通常要提高性能,限制连接,并尝试使用过程而不是直接查询。由于业务规则,我无法使用 procs。我已经尽可能减少了连接数量。

查询调优的下一步是什么?

I have a query that is running slowly. I know generally to make performance faster, limit joins, and try to use procs instead of straight queries. Due to business rules, I cannot use procs. I've already cut the number of joins as much as I can think of.

What's the next step in query tuning?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

假装爱人 2024-09-22 23:21:25

添加索引可能是提高查询性能可以做的第一件事,但您没有提到它。

您是否查看过执行计划,看看是否可以通过附加索引来改进?

此外,您应该确保您的查询以这样的方式编写,以便它们可以使用有效存在的任何索引(例如,避免不可控制的构造,避免*

Adding indexes is probably the number one thing you can do to improve query performance and you haven't mentioned it.

Have you looked at the execution plan to see whether that could be improved with additional indexes?

Additionally you should make sure that your queries are written in such a way so they can use any indexes that are present effectively (e.g. avoid non sargable constructs, avoid *)

静若繁花 2024-09-22 23:21:25

最简单的方法是转到管理工作室运行此命令:

SET SHOWPLAN_ALL ON

然后运行实际查询。

您将不会获得常规查询结果集。它将在结果集中为您提供执行计划(SQL Server 执行查询操作的非常详细的列表)。查看输出并尝试了解它的含义。我通常寻找“SCAN”,这是一个缓慢的部分,我尝试重写它,以便它使用索引。

the easiest thing to do is go to management studio run this command:

SET SHOWPLAN_ALL ON

then run your actual query.

You will not get your regular query result set. It will give you the execution plan (a very detailed list of what SQL Server does to turn your query) in a result set. Look over the output and try to learn what it means. I generally look for "SCAN", that is a slow part, and I try rewriting it so it uses an index.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文