Query Plans
A query plan is a sequence of step-like paths that the Vertica cost-based query optimizer uses to execute queries. Vertica can produce different query plans for a given query. For each query plan, the query optimizer evaluates the data to be queried: number of rows, column statistics such as number of distinct values (cardinality), distribution of data across nodes. It also evaluates available resources such as CPUs and network topology, and other environment factors. The query optimizer uses this information to develop several potential plans. It then compares plans and chooses one, generally the plan with the lowest cost.
Viewing Query Plans
You can obtain query plans in two ways:
- The
EXPLAIN
statement outputs query plans in various text formats. - Management Console provides a graphical interface for viewing query plans. For detailed information, see Managing Queries 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.