Optimizer
Mikito Harakiri, June 02, 2004 - 3:40 pm UTC
"Database System Implementation" textbook by Garcia-Molina et al gives very good descriptin how complex query optimization really is.
Basically, if we focus onto very tiny fragment of the whole process -- enumerating physical plans -- then the number of all possible join combinations is humangous. If we assume that selection operator is aleways pushed down, and that projection is applied "in place" as well, then the number of plans reduced to number of join trees. For the query joining n tables the number of plans is n!*C_n, where C_n is Catalan number (which grows even faster than factorial). Therefore, the second simplification -- considering only left-join trees -- reduces the number of choices to n!.
"Is it really feasible to be able to
explain exactly why the optimizer did what it did?"
10053 exposes enumerating physical plans phase. All other optimiser decisions (e.g. query transformations) are untraceable as of today:-(