Performance of Inner Join vs Cartesian product [duplicate]

有些话、适合烂在心里 提交于 2019-12-18 07:33:18

问题


Possible Duplicate:
Explicit vs implicit SQL joins

I want to know the difference in performance of

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

and

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?


回答1:


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.



来源:https://stackoverflow.com/questions/14644807/performance-of-inner-join-vs-cartesian-product

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!