Question

I read that oracle's CBO(on recent versions) is so good that even if worst possible join order is given, CBO automagically takes the best join order. So will hints like ORDERED do any good on recent versions(10,11)?. Is it possible for the CBO to miss an optimal join order?. Thanks.

Was it helpful?

Solution

My personal experience is that with Oracle 10g / 11g, you can hardly improve any query with hints. Most often they turn out to perform worse the way you think is optimal. The CBO has truly improved drastically.

There are still some (very remote) limitations to the query transformation facilities, especially with rather complex OUTER JOIN constructs, because internally, the ANSI syntax is still mapped to some archaic Oracle constructs involving the (+) operator. Other than that, and other very remote cases, I don't think hints are necessary anymore.

You can tune a lot better by re-writing some SQL, or adding constraints/indexes. Of course, these things hold true only if your statistics and histograms are correct, up-to-date and sensible, as skaffman correctly commented

OTHER TIPS

Oracle CBO results depend on so many parameters, that I can hardly predict the resulting plan in real system. As a general rule I suggest you don't use hints, if you're unsure you must use them.

Regarding ORDERED hint from my experience there're very few times you should tell Oracle the exact order for joins.

Anyway, the best way to find out - is to make some experiments yourself, try out and choose the best solution :)

I suggest you reading Tom Kyte's Effective Oracle by Design - there's a very good chapter on query optimization and how CBO works.

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