Document Information
2,446 Reads | 0 Comments
Description
Have you ever been faced with a SQL statement where you know that if only Oracle would use an index it would perform so much better? Or not use an index, or use a different driving table, or use a hash join, or, or, or … If you are a DBA then this is a rhetorical question. Generally, it is just a matter of using the appropriate hint to solve the problem. However, increasingly DBAs are faced with SQL statements that are generated dynamically by applications, where the source is inaccessible, or which can not be changed because of licensing or support restrictions. This paper will shed some light on the decisions the cost based optimizer (CBO) makes when parsing a SQL statement and choosing an access plan. It will show how the CBO calculates the cost of a plan and some of the rules and factors that go into these calculations. By extrapolation, if you know how the CBO assigned the cost of a plan, you may be able to make changes that lead the optimizer to choose a different plan – without the need to make changes to the SQL statement. While you can not compare the costs of different explain plans, the optimizer does compare the costs of different plans, and chooses the one with the lowest cost, in its current parse tree! You just don’t see any of the plans which “lost out”. Unless you activate the 10053 event trace, that is. There you see all the access plans the CBO evaluated and the costs assigned to them. So, lastly, this paper will act as a guide should you decide to venture into the jungle of a 10053 event trace yourself.
19 Pages