内联与笛卡尔积的表现 [英] Performance of Inner Join vs Cartesian product

查看:407
本文介绍了内联与笛卡尔积的表现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

显式vs隐式SQL连接

我想知道性能差异

select * from A,B,C where A.x = B.y and B.y = C.z

select * from A INNER JOIN B on A.x = B.y INNER JOIN C on B.y = C.z

基本上我想知道如果内部联合比笛卡儿产品更好?
另外,内联是在内部进行的笛卡尔积分?

Basically i want to know if inner join performs better than cartesian product? Also, in inner join is cartesian product carried out internally?

推荐答案

不同的目的,而笛卡尔乘积提供通过将一个表中的每一行连接到另一个表中的每一行而得到的结果。而内连接(有时称为简单连接)是两个或多个表的
连接,仅返回满足连接条件的那些行。
现在来到你所写的这里:

在笛卡尔产品的情况下首先创建一个由A,B,C组成的表,然后根据给出的条件,我们得到结果。但是,当你看到它是沉重的过程。另一方面,内联只选择真正满足给定条件的结果,这是实现最终结果的更好的解决方案。
首先是滥用SQL语言。

First of All these two Operations are for Two different purposes , While Cartesian Product provides you a result made by joining each row from one table to each row in another table. while An inner join (sometimes called a simple join ) is a join of two or more tables that returns only those rows that satisfy the join condition.
Now coming to what You have Written here :
In case of Cartesian product First A table comprising of A,B,C is created and after that on the basis of what ever condition is given,we Get result. But as you see it's heavy process.
On the other hand Inner join only chooses those result which are really fulfilling the given condition .Hence it's a better solution for achieving end results.
First one is abuse of SQL language.

这篇关于内联与笛卡尔积的表现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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