显式联接与隐式联接? [英] Explicit JOINs vs Implicit joins?

查看:120
本文介绍了显式联接与隐式联接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库教授告诉我们使用:

My Database Professor told us to use:

SELECT A.a1, B.b1 FROM A, B WHERE A.a2 = B.b2;

而不是:

SELECT A.a1, B.b1 FROM A INNER JOIN B ON A.a2 = B.b2;

据说Oracle不喜欢JOIN语法,因为这些JOIN语法比笛卡尔乘积的WHERE限制更难优化.

Supposedly Oracle don't likes JOIN-Syntaxes, because these JOIN-syntaxes are harder to optimize than the WHERE restriction of the Cartesian Product.

我无法想象为什么会这样.唯一的性能问题可能是解析器需要再解析几个字符.但这在我眼中微不足道.

I can't imagine why this should be the case. The only Performance issue could be that the parser Needs to parse a few characters more. But that is negligible in my eyes.

我发现了此堆栈溢出问题:

I found this Stack Overflow Questions:

  • Is there an Oracle official recommendation on the use of explicit ANSI JOINs vs implicit joins?
  • Explicit vs implicit SQL joins

Oracle文档中的这一句话: https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries006.htm

And this sentence in a Oracle Documentation: https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries006.htm

Oracle建议您使用FROM子句OUTER JOIN语法,而不要使用Oracle join运算符.

Oracle recommends that you use the FROM clause OUTER JOIN syntax rather than the Oracle join operator.

有人可以通过链接给我来自Oracle的最新建议吗?因为她不承认StackOverflow(在这里可以回答所有人),并且10g文档在这里已经过时了.

Can someone give me up-to-date recommendations from Oracle with link. Because she don't acknowledges StackOverflow (here can answer everyone) and the 10g Documentation is outdated in here eyes.

如果我错了,Oracle真的不喜欢JOINS,那还可以,但是我没有找到文章.我只想知道谁是正确的.

If i am wrong and Oracle realy don't likes JOINS now than thats also ok, but i don't find articles. I just want to know who is Right.

非常感谢能帮助我的每个人!

Thanks a lot to everyone who can help me!

推荐答案

您的教授应与哥伦比亚大学计算机科学教授Gordon Linoff交谈. Gordon和该站点上的大多数SQL爱好者几乎总是会告诉您使用显式联接语法.造成这种情况的原因很多,包括(但不限于):

Your professor should speak with Gordon Linoff, who is a computer science professor at Columbia University. Gordon, and most SQL enthusiasts on this site, will almost always tell you to use explicit join syntax. The reasons for this are many, including (but not limited to):

  • 显式联接使您可以轻松了解实际的联接逻辑.另一方面,隐式联接通过在FROMWHERE子句中散布联接逻辑来模糊联接逻辑.
  • ANSI 92标准建议使用现代显式联接,实际上已弃用了您的教授似乎在推动的隐式联接
  • Explicit joins make it easy to see what the actual join logic is. Implicit joins, on the other hand, obfuscate the join logic, by spreading it out across both the FROM and WHERE clauses.
  • The ANSI 92 standard recommends using modern explicit joins, and in fact deprecated the implicit join which your professor seems to be pushing

就性能而言,据我所知,您编写的查询的两个版本都将在后台优化为同一件事.您始终可以检查两者的执行计划,但是我怀疑您会经常看到很大的不同.

Regarding performance, as far as I know, both versions of the query you wrote would be optimized to the same thing under the hood. You can always check the execution plans of both, but I doubt you would see a significant difference very often.

这篇关于显式联接与隐式联接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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