Question

Is Merge join CARTESIAN always dangerous?

I have many queries with cost ranging from 7 to 40 but follow merge join cartesian for the execution.

When the cost of my query is less, should I really bother about Merge Join cartesian?

I really need help on this.

Any help is greatly appreciated.

Thanks, Savitha

Was it helpful?

Solution

A Cartesian join is usually a sign that you've missed a join somewhere, which is bad in that your result will not be what you expect and the query will likely take substantially longer than it should.

However, that's not always the case. Say you have two relatively small tables that you're filtering down to one row each. Both of these tables will be joined to a much larger table on two different columns, both of which are in the same index. In this case, the optimizer may decide to Cartesian join the two small result sets because the resulting data set can use the index on the larger table more effectively.

In short, if you see a Cartesian join in your plan, you should probably take a closer look and try to understand why the optimizer has chosen that route. It may be that you save yourself a headache down the road because you uncover a bug that hasn't caused a problem yet or it may be that it really is just the best plan, but you have to make that decision for each query separately.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top