To understand the high-level performance considerations for Impala queries, read the
output of the EXPLAIN
statement for the query. You can get the
EXPLAIN
plan without actually running the query itself.
For an overview of the physical performance characteristics for a query, issue the
SUMMARY
statement in impala-shell immediately after
executing a query. This condensed information shows which phases of execution took the
most time, and how the estimates for memory usage and number of rows at each phase compare
to the actual values.
To understand the detailed performance characteristics for a query, issue the
PROFILE
statement in impala-shell immediately after
executing a query. This low-level information includes physical details about memory, CPU,
I/O, and network usage, and thus is only available after the query is actually run.
Also, see Performance Considerations for the Impala-HBase Integration and
Understanding and Tuning Impala Query Performance for S3 Data for examples of interpreting
EXPLAIN
plans for queries against HBase tables and data
stored in the Amazon Simple Storage System (S3).
The EXPLAIN
statement
gives you an outline of the logical steps that a query will perform, such as how the
work will be distributed among the nodes and how intermediate results will be combined
to produce the final result set. You can see these details before actually running the
query. You can use this information to check that the query will not operate in some
very unexpected or inefficient way.
[impalad-host:21000] > EXPLAIN SELECT COUNT(*) FROM customer_address;
+----------------------------------------------------------+
| Explain String |
+----------------------------------------------------------+
| ... |
| |
| 03:AGGREGATE [FINALIZE] |
| | output: sum(count(*)) |
| | |
| 02:EXCHANGE [UNPARTITIONED] |
| | |
| 01:AGGREGATE |
| | output: count(*) |
| | |
| 00:SCAN HDFS [default.customer_address] |
| partitions=1/1 size=5.25MB |
+----------------------------------------------------------+
EXPLAIN
plan from bottom to top:
EXPLAIN_LEVEL
query option, which lets you customize how
much detail to show in the EXPLAIN
plan depending on whether you
are doing high-level or low-level tuning, dealing with logical or physical aspects
of the query.
The EXPLAIN
plan is also printed at the beginning of the query profile
report described in Using the Query Profile for Performance Tuning, for convenience in examining both the
logical and physical aspects of the query side-by-side.
The amount of detail displayed in the EXPLAIN
output is controlled by
the EXPLAIN_LEVEL query
option. You typically increase this setting from standard
to
extended
(or from 1
to 2
) when
doublechecking the presence of table and column statistics during performance tuning, or
when estimating query resource usage in conjunction with the resource management
features.
The
SUMMARY
command within the impala-shell interpreter gives you an
easy-to-digest overview of the timings for the different phases of execution for a
query. Like the EXPLAIN
plan, it is easy to see potential performance
bottlenecks. Like the PROFILE
output, it is available after the query
is run and so displays actual timing numbers.
The SUMMARY
report is also printed at the beginning of the query
profile report described in Using the Query Profile for Performance Tuning, for convenience in examining
high-level and low-level aspects of the query side-by-side.
When the MT_DOP
query option is set to a value larger than
0
, the #Inst
column in the output shows the number of
fragment instances. Impala decomposes each query into smaller units of work that are
distributed across the cluster, and these units are referred as fragments.
When the MT_DOP
query option is set to 0, the #Inst
column in the output shows the same value as the #Hosts
column, since
there is exactly one fragment for each host.
For example, here is a query involving an aggregate function, on a single-node cluster.
The different stages of the query and their timings are shown (rolled up for all nodes),
along with estimated and actual values used in planning the query. In this case, the
AVG()
function is computed for a subset of data on each node (stage 01)
and then the aggregated results from all nodes are combined at the end (stage 03). You
can see which stages took the most time, and whether any estimates were substantially
different than the actual data distribution.
> SELECT AVG(ss_sales_price) FROM store_sales WHERE ss_coupon_amt = 0;
> SUMMARY;
+--------------+--------+--------+----------+----------+-------+------------+----------+---------------+-----------------+
| Operator | #Hosts | #Inst | Avg Time | Max Time | #Rows | Est. #Rows | Peak Mem | Est. Peak Mem | Detail |
+--------------+--------+--------+----------+----------+-------+------------+----------+---------------+-----------------+
| 03:AGGREGATE | 1 | 1 | 1.03ms | 1.03ms | 1 | 1 | 48.00 KB | -1 B | MERGE FINALIZE |
| 02:EXCHANGE | 1 | 1 | 0ns | 0ns | 1 | 1 | 0 B | -1 B | UNPARTITIONED |
| 01:AGGREGATE | 1 | 1 |30.79ms | 30.79ms | 1 | 1 | 80.00 KB | 10.00 MB | |
| 00:SCAN HDFS | 1 | 1 | 5.45s | 5.45s | 2.21M | -1 | 64.05 MB | 432.00 MB | tpc.store_sales |
+--------------+--------+--------+----------+----------+-------+------------+----------+---------------+-----------------+
Notice how the longest initial phase of the query is measured in seconds (s), while later phases working on smaller intermediate results are measured in milliseconds (ms) or even nanoseconds (ns).
The PROFILE
command, available in the impala-shell
interpreter, produces a detailed low-level report showing how the most recent query was
executed. Unlike the EXPLAIN
plan described in
Using the EXPLAIN Plan for Performance Tuning, this information is only available after the
query has finished. It shows physical details such as the number of bytes read, maximum
memory usage, and so on for each node. You can use this information to determine if the
query is I/O-bound or CPU-bound, whether some network condition is imposing a
bottleneck, whether a slowdown is affecting some nodes but not others, and to check that
recommended configuration settings such as short-circuit local reads are in effect.
By default, time values in the profile output reflect the wall-clock time taken by an
operation. For values denoting system time or user time, the measurement unit is
reflected in the metric name, such as ScannerThreadsSysTime
or
ScannerThreadsUserTime
. For example, a multi-threaded I/O operation
might show a small figure for wall-clock time, while the corresponding system time is
larger, representing the sum of the CPU time taken by each thread. Or a wall-clock time
figure might be larger because it counts time spent waiting, while the corresponding
system and user time figures only measure the time while the operation is actively using
CPU cycles.
The EXPLAIN
plan is also printed at the beginning of the query profile report, for
convenience in examining both the logical and physical aspects of the query
side-by-side. The
EXPLAIN_LEVEL query option
also controls the verbosity of the EXPLAIN
output printed by the
PROFILE
command.
In Impala 3.2, a new Per Node Profiles
section
was added to the profile output. The new section includes the following metrics that can
be controlled by the
RESOURCE_TRACE_RATIO
query option.
CpuIoWaitPercentage
CpuSysPercentage
CpuUserPercentage
HostDiskReadThroughput
: All data read by the host as part of the
execution of this query (spilling), by the HDFS data node, and by other processes
running on the same system.
HostDiskWriteThroughput
: All data written by the host as part of the
execution of this query (spilling), by the HDFS data node, and by other processes
running on the same system.
HostNetworkRx
: All data received by the host as part of the execution
of this query, other queries, and other processes running on the same system.
HostNetworkTx
: All data transmitted by the host as part of the
execution of this query, other queries, and other processes running on the same
system.