planner: support "explain analyze format='ru'" to show how TiDB calculate RU
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Enhancement
Below is an example, show the user how we calculate RU for each operator and the plan, which can guide the user to optimize the SQL plan and reduce their costs.
Non-correlated sub-queries and the optimizer and parser RU would be cumulated at the root node, and see `TopN_8's` details below:
```
id task actRows selfRU cumRU cumRU% detail
TopN_8 root 20 0.04 84.31 21.9% sub-query: xxx, optimizer: xxx
└─Selection_7 cop[tikv] 12410 3.12 84.27 21.9% ...
└─TableFullScan_6 cop[tikv] 2000000 81.15 81.15 21.1% 2000000 * ... + ...
```
Contributor guide
Research direction
No files or tests are identified in the issue. Start by locating the EXPLAIN ANALYZE FORMAT handling and the existing RU calculation paths, then compare their operator and plan data with the requested output; done means the example-style RU details are shown for each operator and the plan, including sub-query and optimizer costs at the root.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100