Skip to content

Commit e74a10a

Browse files
dqhl76BohuTANG
andauthored
docs: add explain perf (#2463)
* docs: add `explain perf` * update * update * Update 04-how-to-profiling.md * Update 04-how-to-profiling.md * Update explain-perf.md add introduce version * fix * Update 04-how-to-profiling.md --------- Co-authored-by: Bohu <[email protected]>
1 parent 0d736a5 commit e74a10a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

docs/en/developer/20-community/00-contributor/04-how-to-profiling.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ go tool pprof -http="0.0.0.0:8081" http://localhost:8080/debug/pprof/profile?sec
1111
Open `<your-ip>:8081` and select `Flame Graph` from the VIEW menus in the site header:
1212
<img src="https://user-images.githubusercontent.com/172204/208336392-5b64bb9b-cce8-4562-9e05-c3d538e9d8a6.png"/>
1313

14+
## Query Level CPU Profiling
15+
16+
`EXPLAIN PERF <statement>` can also be used for CPU profiling, which focuses on a specific query and gathers CPU profiling data from other nodes to help analyze query performance. Check [EXPLAIN PERF](/sql/sql-commands/explain-cmds/explain-perf) for more details.
17+
1418
## Memory profiling
1519

1620
`databend-query` and `databend-meta` can be built optionally with `jemalloc`,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: EXPLAIN PERF
3+
---
4+
5+
import FunctionDescription from '@site/src/components/FunctionDescription';
6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
9+
<FunctionDescription description="Introduced or updated: v1.2.765"/>
10+
11+
`EXPLAIN PERF` captures stack traces to perform CPU profiling. This command returns an HTML file containing flame graphs generated from data collected from all nodes in the current cluster. You can directly open this HTML file in your browser.
12+
13+
It is helpful to analyze query performance and help identify bottlenecks.
14+
15+
## Syntax
16+
17+
```sql
18+
EXPLAIN PERF <statement>
19+
```
20+
21+
## Examples
22+
23+
```shell
24+
bendsql --quote-style never --query="EXPLAIN PERF SELECT avg(number) FROM numbers(10000000)" > demo.html
25+
```
26+
27+
Then, you can open the `demo.html` file in your browser to view the flame graphs:
28+
29+
<img src="https://github.com/user-attachments/assets/07acfefa-a1c3-4c00-8c43-8ca1aafc3224"/>
30+
31+
If the query finishes very quickly, it may not collect enough data, resulting in an empty flame graph.

0 commit comments

Comments
 (0)