Skip to content

Commit b5a2274

Browse files
EXPLAIN ANALYZE GRAPHICAL (#1989)
Co-authored-by: z <[email protected]>
1 parent de2a08f commit b5a2274

File tree

2 files changed

+50
-34
lines changed

2 files changed

+50
-34
lines changed

docs/en/sql-reference/10-sql-commands/40-explain-cmds/explain-analyze-graphical.md

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,66 @@ title: EXPLAIN ANALYZE GRAPHICAL
44

55
import FunctionDescription from '@site/src/components/FunctionDescription';
66

7-
<FunctionDescription description="Introduced: v1.2.647"/>
7+
<FunctionDescription description="Introduced or updated: v1.2.647"/>
88

9-
`EXPLAIN ANALYZE GRAPHICAL` used to open a browser page to display a query execution plan along with actual run-time performance statistics.
9+
`EXPLAIN ANALYZE GRAPHICAL` is a command available exclusively in the BendSQL client. It allows you to analyze the performance and execution plan of a SQL query by automatically launching your default browser and presenting an interactive visual representation of the query execution process.
1010

11-
This is useful for analyzing query performance and identifying bottlenecks in a query.
12-
13-
**Note:** This feature is available only in BendSQL.
11+
This command is supported only in BendSQL v0.22.2 and above. Before using it, ensure that your BendSQL is properly configured. For setup instructions, see [Configuring BendSQL](#configuring-bendsql).
1412

1513
## Syntax
1614

1715
```sql
1816
EXPLAIN ANALYZE GRAPHICAL <statement>
1917
```
2018

19+
## Configuring BendSQL
20+
21+
To enable graphical analysis and automatically open your default browser, add the following section to your BendSQL configuration file `~/.config/bendsql/config.toml`:
22+
23+
```toml
24+
[server]
25+
bind_address = "127.0.0.1"
26+
auto_open_browser = true
27+
```
28+
2129
## Examples
2230

23-
TPC-H Q21:
31+
You can use `EXPLAIN ANALYZE GRAPHICAL` to analyze the performance of complex queries, such as TPC-H benchmark queries, and understand how each part of the query contributes to overall execution time.
2432

25-
```sql
26-
EXPLAIN ANALYZE GRAPHICAL SELECT s_name,
27-
-> Count(*) AS numwait
28-
-> FROM supplier,
29-
-> lineitem l1,
30-
-> orders,
31-
-> nation
32-
-> WHERE s_suppkey = l1.l_suppkey
33-
-> AND o_orderkey = l1.l_orderkey
34-
-> AND o_orderstatus = 'F'
35-
-> AND l1.l_receiptdate > l1.l_commitdate
36-
-> AND EXISTS (SELECT *
37-
-> FROM lineitem l2
38-
-> WHERE l2.l_orderkey = l1.l_orderkey
39-
-> AND l2.l_suppkey <> l1.l_suppkey)
40-
-> AND NOT EXISTS (SELECT *
41-
-> FROM lineitem l3
42-
-> WHERE l3.l_orderkey = l1.l_orderkey
43-
-> AND l3.l_suppkey <> l1.l_suppkey
44-
-> AND l3.l_receiptdate > l3.l_commitdate)
45-
-> AND s_nationkey = n_nationkey
46-
-> AND n_name = 'EGYPT'
47-
-> GROUP BY s_name
48-
-> ORDER BY numwait DESC,
49-
-> s_name
50-
-> LIMIT 100;
51-
52-
// will open a browser page to display the query execution plan and performance statistics.
33+
Here is an example query that calculates aggregates from the `lineitem` table:
34+
35+
```bash
36+
eric@(eric-xsmall)/tpch_100> EXPLAIN ANALYZE GRAPHICAL select
37+
l_returnflag,
38+
l_linestatus,
39+
sum(l_quantity) as sum_qty,
40+
sum(l_extendedprice) as sum_base_price,
41+
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
42+
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
43+
avg(l_quantity) as avg_qty,
44+
avg(l_extendedprice) as avg_price,
45+
avg(l_discount) as avg_disc,
46+
count(*) as count_order
47+
from
48+
lineitem
49+
where
50+
l_shipdate <= add_days(to_date('1998-12-01'), -90)
51+
group by
52+
l_returnflag,
53+
l_linestatus
54+
order by
55+
l_returnflag,
56+
l_linestatus;
5357
```
58+
59+
After running the command, BendSQL outputs a message like:
60+
61+
```bash
62+
View graphical online: http://127.0.0.1:8080?perf_id=1
63+
64+
1095 rows graphical in 21.762 sec. Processed 0 rows, 0 B (0 row/s, 0 B/s)
65+
```
66+
67+
This automatically opens your default browser and shows an interactive graphical view of the query execution plan, including operator runtimes, row counts, and data flow between stages.
68+
69+
![alt text](@site/static/img/documents/sql/explain-graphical.png)
325 KB
Loading

0 commit comments

Comments
 (0)