Viewing Query Plans

You can obtain query plans in two ways:

  • The EXPLAIN statement outputs query plans in various text formats (see below).
  • Management Console provides a graphical interface for viewing query plans. For detailed information, see Working with Query Plans in MC in Using Management Console.

You can also observe the real-time flow of data through a query plan by querying the system table QUERY_PLAN_PROFILES. For more information, see Profiling Query Plans.

EXPLAIN Output Options

By default, EXPLAIN output represents the query plan as a hierarchy, where each level, or path, represents a single database operation that the optimizer uses to execute a query. EXPLAIN output also appends DOT language source so you can display this output graphically with open source Graphviz tools.

EXPLAIN supports options for producing verbose and JSON output. You can also show the local query plans that are assigned to each node, which together comprise the total (global) query plan.

EXPLAIN also supports an ANNOTATED option. EXPLAIN ANNOTATED returns a query with embedded optimizer hints, which encapsulate the query plan for this query. For an example of usage, see Using Optimizer-Generated and Custom Directed Queries Together.

In This Section