Performance of Inner Join vs Cartesian product

nishantv picture nishantv · Feb 1, 2013 · Viewed 19.5k times · Source

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?

Answer

user1909647 picture user1909647 · Feb 1, 2013

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.