Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle cartesian product vs. join

In my company we use an Oracle database. I've noticed everybody writes their queries like this:

SELECT p.name, p.id, o.issued_date
FROM orders o, products p
WHERE o.productid = p.id;

What is the database doing in a situation like this? Making a Cartesian product and then selecting only certain rows? That just doesn't sound right.

like image 634
Robotronx Avatar asked Feb 18 '23 16:02

Robotronx


1 Answers

What is the database doing in a situation like this?

The same as when you specify an ANSI join:

SELECT *
FROM orders o
JOIN products p ON o.productid = p.id

I've noticed everybody writes their queries like this [...]

It looks like lots of people in your company got many years of experience in Oracle! I bet they also use (+) notation for outer joins. This was the only syntax supported by Oracle prior to the 9i release.

like image 56
Sergey Kalinichenko Avatar answered Feb 28 '23 07:02

Sergey Kalinichenko