pingcap / pingcap/tidb

Rearrange logical optimizing rule

Open
#55,231 18 comments 4 reactions 0 assignees View on GitHub
good first issue help wanted sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

This is a special topic campaign about first-time contributions that are friendly for academic open-source credits, with no hard-core database logic inside. Still, it is a great window for stepping deep into the charm of TiDB optimizer. Here is an example, https://github.com/pingcap/tidb/pull/55226, this pull request contain the interface refactoring, you should focus on the change of [rule_build_key_info.go](https://github.com/pingcap/tidb/pull/55226/files#diff-a05bec52a5eba2058035bf96c2759d3b902e9f85b0a970c81b03a33d46870251) about moving and classifying current logical rules.

currently, tidb optimizing logical rules are put in the planner/core pkg with the prefix `rule_`, inside these files it may rely on logical operator pkg to do the type check and rule asserting. Some of it may have little coupling with `planner/core` pkg itselves. When we try to move and classify these rules into `planner/rule` pkg, we should think twice about how to solve these back awards dependencies. The healthy pkg reference graph should be like below:

image

some special cases'(complex rule file migrating) scope will become even bigger than the pictures show, you can contact me @AilinKid and @hawkingrei to talk about it.

You are appreciated for making a detailed description of what your pull request has done. Of course,
* first, you should claim and comment on which rule_file you picked behind this issue, click the checkbox below at the same time,
* then, after you go through the code, you can modify the same comment to add what's your basic idea about it.
* after @AilinKid and @hawkingrei approve your idea, you can file your pull request. This is to avoid wasting time on the wrong way too much, describing your idea is much cheaper, isn't it? Thank you so much for reading until here.

- [x] rule_aggregation_elimination.go @minami-lvgs
- [ ] rule_aggregation_push_down.go
- [ ] rule_aggregation_skew_rewrite.go
- [x] rule_collect_plan_stats.go @hawkingrei
- [ ] rule_column_pruning.go
- [x] rule_constant_propagation.go @qingfeng777
- [ ] rule_decorrelate.go
- [ ] rule_derive_topn_from_window.go
- [ ] rule_eliminate_projection.go
- [ ] rule_generate_column_substitute.go
- [ ] rule_inject_extra_projection.go
- [ ] rule_join_elimination.go
- [x] rule_join_reorder.go
- [x] rule_join_reorder_dp.go
- [x] rule_join_reorder_greedy.go
- [ ] rule_max_min_eliminate.go
- [ ] rule_outer_to_inner_join.go
- [ ] rule_partition_processor.go
- [ ] rule_predicate_push_down.go
- [ ] rule_predicate_simplification.go
- [ ] rule_push_down_sequence.go
- [ ] rule_resolve_grouping_expand.go
- [ ] rule_result_reorder.go
- [ ] rule_semi_join_rewrite.go
- [x] rule_topn_push_down.go @orthur2

### First Time Contributor
first time contributor with tag in your pull request like below
![image](https://github.com/user-attachments/assets/74afadb3-d096-449e-bca7-2af25a1a46c4)
After it merged, you can reach @billmay for your souvenir

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.