Link to home
Start Free TrialLog in
Avatar of rajannagpal
rajannagpal

asked on

does Cartesian product happens each time we execute joins

Hi guys

Does the oracle always does the cartesian product before filtering out the records based on join condition

For example
      select * from category_new, category_temp where
     category_new.category = category_temp.category

what will happen in this case will the oracle behind the scene fetch all the records from both the tables, then perform cartesian product and then apply equi join.

Is this the case that oracle will perform cartesian product each time we ask for join ?
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

the answer is: it depends.

functionally, yes. however, technically, depending on the indexes you have on the tables, it will perform either a index-based row-lookup, a merge join, etc.

run the explain plan for the query, and you will know.
Avatar of rajannagpal
rajannagpal

ASKER

I run the explain plan and reach the conclusion that oracle always perform cartesian product. I was suspicious about the result that why i need to verify.  

so question is if we dont have indexes and assume we are going by book then what will happen, will it perform the cartesian product ?
yes.
this is why indexes are crutial, the bigger the table, the more important they are.
ASKER CERTIFIED SOLUTION
Avatar of Sujith
Sujith
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial