The optimizer will have to remember this best plan even when it considers a different join order for the outer query, because it's possible that the subquery's best plan for that optimization will be the best one overall.

It occurs to me that the code structure already supports this. Every time the optimizer figures out the best access path for an optimizable in the context of a join order it's considering, it tells the optimizable to remember that access path as the "best," and when it finds a complete plan that's the best so far, it tells the optimizable to remember it as "truly the best." When optimizing an outer query containing a table subquery, the "best" and "truly the best" access paths for the subquery should be the complete plan for the subquery from the current (or latest) optimization of it.


                       -        Jeff Lichtman
                                [EMAIL PROTECTED]
                                Check out Swazoo Koolak's Web Jukebox at
http://swazoo.com/

Reply via email to