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.
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.