<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Plan Order</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2012/11/21/plan-order/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2012/11/21/plan-order/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Sat, 18 May 2013 11:04:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/11/21/plan-order/#comment-52100</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 13 Dec 2012 21:41:52 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9940#comment-52100</guid>
		<description><![CDATA[Abel,

Thanks for the description - its a very useful insight into the way we should think about interpreting execution plans. It raises a couple of question, though, most significantly:  Is there anything in, or that could be added to, the plan table that could allow an automatic analysis of the plan table to show that the subquery at line 5 was going to run first without having to do a semantic analysis of the filter predicate on line 1 ? As it stands I can infer that line 5 will execute before line 2 - but only because I can work out that line 5 represents what I called a &quot;constant subquery&quot; - but I can&#039;t think of any way to analyze the plan table to make that inference within an SQL or PL/SQL script.

I&#039;d be prepared to bet that if you ran this plan through OEM and displayed the pages that shows the execution plan for a query with the column showing order of operation, the ordering would be wrong because the code to calculate the order uses (or seems to use) the traditional &quot;first child first&quot; model, and it would be nice if OEM could get these things right.]]></description>
		<content:encoded><![CDATA[<p>Abel,</p>
<p>Thanks for the description &#8211; its a very useful insight into the way we should think about interpreting execution plans. It raises a couple of question, though, most significantly:  Is there anything in, or that could be added to, the plan table that could allow an automatic analysis of the plan table to show that the subquery at line 5 was going to run first without having to do a semantic analysis of the filter predicate on line 1 ? As it stands I can infer that line 5 will execute before line 2 &#8211; but only because I can work out that line 5 represents what I called a &#8220;constant subquery&#8221; &#8211; but I can&#8217;t think of any way to analyze the plan table to make that inference within an SQL or PL/SQL script.</p>
<p>I&#8217;d be prepared to bet that if you ran this plan through OEM and displayed the pages that shows the execution plan for a query with the column showing order of operation, the ordering would be wrong because the code to calculate the order uses (or seems to use) the traditional &#8220;first child first&#8221; model, and it would be nice if OEM could get these things right.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2012/11/21/plan-order/#comment-52093</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Thu, 13 Dec 2012 18:35:59 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9940#comment-52093</guid>
		<description><![CDATA[Srivenu,

The oddity in those plans (where the hash join swaps the join input) is that the order in which the tables are joined is not the order in which they appear in the plan. The order in which the operations run is still (except for certain parallel plans) the order you would expect from the &quot;traditional&quot; descent through the plan.]]></description>
		<content:encoded><![CDATA[<p>Srivenu,</p>
<p>The oddity in those plans (where the hash join swaps the join input) is that the order in which the tables are joined is not the order in which they appear in the plan. The order in which the operations run is still (except for certain parallel plans) the order you would expect from the &#8220;traditional&#8221; descent through the plan.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guillaume Goulet-Vallières</title>
		<link>http://jonathanlewis.wordpress.com/2012/11/21/plan-order/#comment-51745</link>
		<dc:creator><![CDATA[Guillaume Goulet-Vallières]]></dc:creator>
		<pubDate>Fri, 30 Nov 2012 21:11:10 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9940#comment-51745</guid>
		<description><![CDATA[Very interessting indeed, thanks for sharing !]]></description>
		<content:encoded><![CDATA[<p>Very interessting indeed, thanks for sharing !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: abel</title>
		<link>http://jonathanlewis.wordpress.com/2012/11/21/plan-order/#comment-51685</link>
		<dc:creator><![CDATA[abel]]></dc:creator>
		<pubDate>Wed, 28 Nov 2012 14:13:08 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9940#comment-51685</guid>
		<description><![CDATA[Oracle does not starts the execution from the driving table right out the bat.
When you have a query that has contradictory predicates (a=1 and a=2) then Oracle realizes it is contradictory and it is pulled up as far as possible so the steps below are not executed.
it initializes each step from bottom to top starting from the first line so if there is a predicate that can stop the execution of the remaining dependent steps.
All steps are probed to see if they can be resolved completely or have a dependency. Resolve that dependency and then come back to execute.

so really the execution is :
Initialize FILTER in step 1. if filter can be resolved completely then it is done. if it has a dependency then resolve it and then proceed with next step.
The dependency in this case is the subquery in step 5. 
The join in step 3 is not initialized until the step 5 is resolved at least once.
Step 5 is initialized and resolved and returns execution to step 1.
Since all dependencies of 1 are resolved then it can proceed but since the results of step 5 does not match the criteria then it stops.]]></description>
		<content:encoded><![CDATA[<p>Oracle does not starts the execution from the driving table right out the bat.<br />
When you have a query that has contradictory predicates (a=1 and a=2) then Oracle realizes it is contradictory and it is pulled up as far as possible so the steps below are not executed.<br />
it initializes each step from bottom to top starting from the first line so if there is a predicate that can stop the execution of the remaining dependent steps.<br />
All steps are probed to see if they can be resolved completely or have a dependency. Resolve that dependency and then come back to execute.</p>
<p>so really the execution is :<br />
Initialize FILTER in step 1. if filter can be resolved completely then it is done. if it has a dependency then resolve it and then proceed with next step.<br />
The dependency in this case is the subquery in step 5.<br />
The join in step 3 is not initialized until the step 5 is resolved at least once.<br />
Step 5 is initialized and resolved and returns execution to step 1.<br />
Since all dependencies of 1 are resolved then it can proceed but since the results of step 5 does not match the criteria then it stops.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srivenu kadiyala</title>
		<link>http://jonathanlewis.wordpress.com/2012/11/21/plan-order/#comment-51648</link>
		<dc:creator><![CDATA[srivenu kadiyala]]></dc:creator>
		<pubDate>Mon, 26 Nov 2012 17:17:46 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9940#comment-51648</guid>
		<description><![CDATA[Jonathan,
Since you are posting about plan order oddities, i wanted to point out one frequent oddity thats encountered (especially in DW environments), the right deep queries with hash joins. (I even remember reading a note from you about that - long time back).]]></description>
		<content:encoded><![CDATA[<p>Jonathan,<br />
Since you are posting about plan order oddities, i wanted to point out one frequent oddity thats encountered (especially in DW environments), the right deep queries with hash joins. (I even remember reading a note from you about that &#8211; long time back).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sayan Malakshinov</title>
		<link>http://jonathanlewis.wordpress.com/2012/11/21/plan-order/#comment-51585</link>
		<dc:creator><![CDATA[Sayan Malakshinov]]></dc:creator>
		<pubDate>Wed, 21 Nov 2012 19:29:56 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=9940#comment-51585</guid>
		<description><![CDATA[Thanks for explanation, just today, spoke with colleague about the order from the previous your post.]]></description>
		<content:encoded><![CDATA[<p>Thanks for explanation, just today, spoke with colleague about the order from the previous your post.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
