加入会减慢sql [英] Join slows down sql

查看:55
本文介绍了加入会减慢sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们对SQL Server 2008进行了讨论并加入.一半的人说,加入的越多,sql运行的越慢.另一半说,这没关系,因为SQL Server负责事务处理,因此您不会注意到任何性能损失.什么是真的?

We have a discussion over SQL Server 2008 and join. One half says the more joins the slower you sql runs. The other half says ihat it does not matter because SQL server takes care of business so you wil not notice any performance loss. What is true?

推荐答案

与其以自己的方式提问,不如考虑:

Instead of asking the question the way you have, consider instead:

  • 是否可以在没有联接的情况下获取所需的数据?
    • 否=>您需要参加讨论,然后结束.
    • Can I get the data I want without the join?
      • No => You need the join, end of discussion.

      这也是一个程度的问题.联接不可能添加其他处理.即使Query Optimizer将其删除(例如,左连接而联接中没有使用任何东西),解析它仍然要花费CPU周期.

      It is also a matter of degree. It is impossible for a join not to add additional processing. Even if the Query Optimizer takes it out (e.g. left join with nothing used from the join) - it still costs CPU cycles to parse it.

      现在,如果有关比较的问题与另一种技术有关,例如在record in X not in Y情况下LEFT JOIN + IS NULL与NOT EXISTS的一种特殊情况,那么让我们讨论一下具体内容-表大小(X与Y),索引等.

      Now if the question is about comparing joins to another technique, such as one special case of LEFT JOIN + IS NULL vs NOT EXISTS for a record in X not in Y scenario, then let's discuss specifics - table sizes (X vs Y), indexes etc.

      这篇关于加入会减慢sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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