pingcap / pingcap/tidb

Make extracting information from execution plans easier in the code and reduce the repeated code

Open
#35,888 0 comments 0 reactions 1 assignee Claimed by @time-and-fate View on GitHub
type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

Currently, in tidb code, when we want to get some information from an execution plan, we have to implement a method for the `planner/core.Plan` type. Usually, we have to iterate through the tree in the method. And sometimes, we will collect some basic information in different places.

This causes some unnecessary repeated code and some bugs:
#28731 Generating the execution plan text from a `Plan` is repeated for the `EXPLAIN` statement, statements summary, and slow log/slow query. And their results are different.
#35687 The logic of iterating the plan tree is updated because of new operators, but only for `EXPLAIN` statements. The logic for stmt summary and the slow query/log is missed.

And we are still adding more methods to extract different information from `Plan` in different places. So it's better if we can make it more convenient and reduce repeated code.

A possible solution: https://github.com/pingcap/tidb/issues/28731#issuecomment-1065075037

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.