Search code examples
oracle-sqldeveloperquery-optimizationoracle12cdatabase-administration

Are the grey rows in the execution plan in SQL Developer executed?


When I get an explain plan of a query, I see that some of the rows in the plan is grey. As have heard from someone that these grey lines actually are not executed. And I'm actually confused. If the database will not use these steps, why do these lines are there in the plan then?

If all the rows are used actually, so why there are two reads for the VME_SPEND_ITEM_MAR_18 table?

Note: This plan is an explain plan taken by the explain plan button in SQL Developer. So it is not an actual execution plan.

Here is the image of the explain plan :

enter image description here

Best Regards..


Solution

  • As have heard from someone that these grey lines actually are not executed

    Because you're looking at an adaptive plan - and your 'someone' is right.

    In other words, Oracle creates an execution plan for your query...starts to run it, starts to notice things are going different than expected, and on-the-fly makes a course correction.

    This is a gross oversimplification, but you can get a real introduction to the feature here.

    In your plan, there's a item there to do Stats Collection on your table - the optimizer has gone and looked at the data involved for that query predicates (date range) and the number of rows indicated by stats are WAAAY off, so at that point the optimizer says back up, we're gonna go a different route.

    This is a new feature for Database 12c, you've tagged Oracle11g, but this plan tells us we're on 12.

    If you scroll down just a bit in your plan there in SQL Developer, you'll see that the Database is telling you the Adaptive Plan feature is in play

    enter image description here