Description
Supported engines: Presto and SparkSQL
Applicable table: Native and external tables
Purpose: Display logical or physical plan for executing SQL statements.
Statement
Presto
EXPLAIN [ ( option [, ...] ) ] statement
-- where option can be one of:
-- FORMAT { TEXT | GRAPHVIZ | JSON }
-- TYPE { LOGICAL | DISTRIBUTED | VALIDATE | IO }
SparkSQL
EXPLAIN [ EXTENDED | CODEGEN | COST | FORMATTED ] statement
EXPLAIN ANALYZE
EXPLAIN ANALYZE [VERBOSE] statement
Example
-- presto
EXPLAIN (TYPE VALIDATE) SELECT regionkey, count(*) FROM nation GROUP BY 1;
EXPLAIN (TYPE IO, FORMAT JSON) INSERT INTO test_nation SELECT * FROM nation WHERE regionkey = 2;
-- EXPLAIN ANALYZE
EXPLAIN ANALYZE SELECT count(*), clerk FROM orders WHERE orderdate > date '1995-01-01' GROUP BY clerk;
EXPLAIN ANALYZE VERBOSE SELECT count(clerk) OVER() FROM orders WHERE orderdate > date '1995-01-01';
Was this page helpful?