risinglightdb / risinglight

An educational OLAP database system.
Apache License 2.0
1.59k stars 211 forks source link

feat: support `EXPLAIN ANALYZE` to profile queries #849

Closed wangrunji0408 closed 2 months ago

wangrunji0408 commented 4 months ago

Signed-off-by: Runji Wang wangrunji0408@163.com

Inspired by duckdb's EXPLAIN ANALYZE.

Example of TPCH Q6 ```sql explain analyze select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= date '1994-01-01' and l_shipdate < date '1994-01-01' + interval '1' year and l_discount between 0.08 - 0.01 and 0.08 + 0.01 and l_quantity < 24; Projection ├── exprs:ref │ └── sum │ └── * { lhs: l_discount, rhs: l_extendedprice } ├── rows: 1 ├── time: 91.042µs └── Agg ├── aggs:sum │ └── * { lhs: l_discount, rhs: l_extendedprice } ├── rows: 1 ├── time: 4.525204ms └── Filter ├── cond: and { lhs: >= { lhs: 0.09, rhs: l_discount }, rhs: >= { lhs: l_discount, rhs: 0.07 } } ├── rows: 113920 ├── time: 14.407315ms └── Projection { exprs: [ l_extendedprice, l_discount ], rows: 417809, time: 2.277959ms } └── Filter ├── cond:and │ ├── lhs: > { lhs: 24, rhs: l_quantity } │ └── rhs:and │ ├── lhs: > { lhs: 1995-01-01, rhs: l_shipdate } │ └── rhs: >= { lhs: l_shipdate, rhs: 1994-01-01 } ├── rows: 417809 ├── time: 69.414093ms └── Scan ├── table: lineitem ├── list: [ l_quantity, l_extendedprice, l_discount, l_shipdate ] ├── filter: true ├── rows: 6001215 └── time: 289.72746ms ```