开发者

Join slows down sql [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

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.

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.

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.


It will slow it down: the more complicated a query, the more work the database server has to do to execute it.

But about that "performance loss": over what? Is there another way to get at the same data? If so, then you can profile the various options against each other to see which is fastest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜