nerdexam
Oracle

1Z0-062 · Question #40

Examine the parameter for your database instance: You generated the execution plan for the following query in the plan table and noticed that the nested loop join was done. After actual execution of…

The correct answer is A. The optimizer used a dynamic plan for the query. Oracle Adaptive Query Optimization allows the optimizer to embed decision points in the compiled plan and choose the actual join method at runtime based on observed row counts, which is why EXPLAIN PLAN and actual execution can show different joins.

Managing Performance

Question

Examine the parameter for your database instance:

You generated the execution plan for the following query in the plan table and noticed that the nested loop join was done. After actual execution of the query, you notice that the hash join was done in the execution plan:

Identify the reason why the optimizer chose different execution plans.

Exhibits

1Z0-062 question #40 exhibit 1
1Z0-062 question #40 exhibit 2

Options

  • AThe optimizer used a dynamic plan for the query.
  • BThe optimizer chose different plans because automatic dynamic sampling was enabled.
  • CThe optimizer used re-optimization cardinality feedback for the query.
  • DThe optimizer chose different plan because extended statistics were created for the columns

How the community answered

(45 responses)
  • A
    62% (28)
  • B
    7% (3)
  • C
    20% (9)
  • D
    11% (5)

Why each option

Oracle Adaptive Query Optimization allows the optimizer to embed decision points in the compiled plan and choose the actual join method at runtime based on observed row counts, which is why EXPLAIN PLAN and actual execution can show different joins.

AThe optimizer used a dynamic plan for the query.Correct

Starting in Oracle 12c, Adaptive Plans (part of Adaptive Query Optimization) let the optimizer produce a default plan containing embedded statistics collector operators at key join points. During execution, these collectors measure actual row counts flowing through the plan and, if cardinality differs significantly from estimates, the optimizer switches to an alternative sub-plan - for example replacing a nested loop with a hash join - without requiring a re-parse. This is precisely why EXPLAIN PLAN (which shows the compile-time default) can display a nested loop while the actual execution uses a hash join.

BThe optimizer chose different plans because automatic dynamic sampling was enabled.

Automatic dynamic sampling refines cardinality estimates at parse time before generating the plan, so it cannot cause a runtime switch between two join methods during a single execution.

CThe optimizer used re-optimization cardinality feedback for the query.

Cardinality feedback from re-optimization feeds corrected row count estimates back into the optimizer only for subsequent executions of the same query, not during the first execution described here.

DThe optimizer chose different plan because extended statistics were created for the columns

Extended statistics improve join-column group cardinality estimates at parse time, but they do not create a mechanism for the optimizer to change join methods between the plan display and actual execution.

Concept tested: Oracle Adaptive Query Optimization and adaptive plan execution

Source: https://docs.oracle.com/en/database/oracle/oracle-database/19/tgsql/adaptive-query-optimization.html

Topics

#Execution plan#Optimizer behavior#Dynamic plan#Cardinality feedback#Adaptive plans

Community Discussion

No community discussion yet for this question.

Full 1Z0-062 Practice