pingcap / pingcap/tidb

Refine building ranges logic

Open
#37,176 0 comments 0 reactions 1 assignee Claimed by @xuyifangreeneyes View on GitHub
sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

Currently the logic of building ranges has following problems:
1. No memory control. We can construct the case like #30755 to let TiDB OOM by building too many ranges.
2. Building ranges is expensive. When there is a long `IN` list in query, it takes lots of CPU and generates lots of temporary small objects, which leads to frequency GC.
3. The logic of building ranges is complex and not easy to read. Maybe we can refactor it step by step.

### memory control for building ranges

- [x] https://github.com/pingcap/tidb/pull/37160
- [x] https://github.com/pingcap/tidb/pull/37706
- [x] https://github.com/pingcap/tidb/pull/37714
- [x] https://github.com/pingcap/tidb/pull/37754
- [x] https://github.com/pingcap/tidb/pull/38129
- [x] https://github.com/pingcap/tidb/pull/37835
- [x] https://github.com/pingcap/tidb/pull/37769
- [x] https://github.com/pingcap/tidb/pull/38592
- [x] https://github.com/pingcap/tidb/pull/38694
- [x] https://github.com/pingcap/docs-cn/pull/11239

### reduce cost for building ranges
- [x] https://github.com/pingcap/tidb/pull/37177

### refactor for building ranges
- [x] https://github.com/pingcap/tidb/pull/37178
- [x] https://github.com/pingcap/tidb/pull/37831
- [x] https://github.com/pingcap/tidb/pull/38100

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.