EXPLAIN ANALYZE

摘要

  1. EXPLAIN ANALYZE [VERBOSE] statement

说明

执行语句并显示语句的分布式执行计划以及每个操作的开销。

VERBOSE 选项可提供更详细的信息和具体的统计数据;了解这些信息可能需要了解 openLooKeng 内部细节和实现细节。

注意

统计数据可能不完全准确,尤其是对于快速完成的查询。

示例

在下面的示例中,您可以看到每个阶段消耗的 CPU 时间,以及该阶段中每个计划节点的相对开销。请注意,计划节点的相对开销基于挂钟时间,挂钟时间可能与 CPU 时间相关,也可能与之不相关。对于每个计划节点,您都可以看到一些额外的统计数据(例如每个节点实例的平均输入以及相关计划节点的平均哈希冲突数)。当您希望检测查询的数据异常(偏斜、异常哈希冲突)时,这些统计数据很有用。

  1. lk:sf1> EXPLAIN ANALYZE SELECT count(*), clerk FROM orders WHERE orderdate > date '1995-01-01' GROUP BY clerk;
  2. Query Plan
  3. -----------------------------------------------------------------------------------------------
  4. Fragment 1 [HASH]
  5. Cost: CPU 88.57ms, Input: 4000 rows (148.44kB), Output: 1000 rows (28.32kB)
  6. Output layout: [count, clerk]
  7. Output partitioning: SINGLE []
  8. - Project[] => [count:bigint, clerk:varchar(15)]
  9. Cost: 26.24%, Input: 1000 rows (37.11kB), Output: 1000 rows (28.32kB), Filtered: 0.00%
  10. Input avg.: 62.50 lines, Input std.dev.: 14.77%
  11. - Aggregate(FINAL)[clerk][$hashvalue] => [clerk:varchar(15), $hashvalue:bigint, count:bigint]
  12. Cost: 16.83%, Output: 1000 rows (37.11kB)
  13. Input avg.: 250.00 lines, Input std.dev.: 14.77%
  14. count := "count"("count_8")
  15. - LocalExchange[HASH][$hashvalue] ("clerk") => clerk:varchar(15), count_8:bigint, $hashvalue:bigint
  16. Cost: 47.28%, Output: 4000 rows (148.44kB)
  17. Input avg.: 4000.00 lines, Input std.dev.: 0.00%
  18. - RemoteSource[2] => [clerk:varchar(15), count_8:bigint, $hashvalue_9:bigint]
  19. Cost: 9.65%, Output: 4000 rows (148.44kB)
  20. Input avg.: 4000.00 lines, Input std.dev.: 0.00%
  21. Fragment 2 [tpch:orders:1500000]
  22. Cost: CPU 14.00s, Input: 818058 rows (22.62MB), Output: 4000 rows (148.44kB)
  23. Output layout: [clerk, count_8, $hashvalue_10]
  24. Output partitioning: HASH [clerk][$hashvalue_10]
  25. - Aggregate(PARTIAL)[clerk][$hashvalue_10] => [clerk:varchar(15), $hashvalue_10:bigint, count_8:bigint]
  26. Cost: 4.47%, Output: 4000 rows (148.44kB)
  27. Input avg.: 204514.50 lines, Input std.dev.: 0.05%
  28. Collisions avg.: 5701.28 (17569.93% est.), Collisions std.dev.: 1.12%
  29. count_8 := "count"(*)
  30. - ScanFilterProject[table = tpch:tpch:orders:sf1.0, originalConstraint = ("orderdate" > "$literal$date"(BIGINT '9131')), filterPredicate = ("orderdate" > "$literal$date"(BIGINT '9131'))] => [cler
  31. Cost: 95.53%, Input: 1500000 rows (0B), Output: 818058 rows (22.62MB), Filtered: 45.46%
  32. Input avg.: 375000.00 lines, Input std.dev.: 0.00%
  33. $hashvalue_10 := "combine_hash"(BIGINT '0', COALESCE("$operator$hash_code"("clerk"), 0))
  34. orderdate := tpch:orderdate
  35. clerk := tpch:clerk

使用 VERBOSE 选项后,某些运算符可能会报告额外的信息。例如,窗口函数运算符将输出以下信息:

  1. EXPLAIN ANALYZE VERBOSE SELECT count(clerk) OVER() FROM orders WHERE orderdate > date '1995-01-01';
  2. Query Plan
  3. -----------------------------------------------------------------------------------------------
  4. ...
  5. - Window[] => [clerk:varchar(15), count:bigint]
  6. Cost: {rows: ?, bytes: ?}
  7. CPU fraction: 75.93%, Output: 8130 rows (230.24kB)
  8. Input avg.: 8130.00 lines, Input std.dev.: 0.00%
  9. Active Drivers: [ 1 / 1 ]
  10. Index size: std.dev.: 0.00 bytes , 0.00 rows
  11. Index count per driver: std.dev.: 0.00
  12. Rows per driver: std.dev.: 0.00
  13. Size of partition: std.dev.: 0.00
  14. count := count("clerk")
  15. ...

另请参见

EXPLAIN