Skip to content

Add filter in /pd/api/v1/stats/region API #5607

@hehechen

Description

@hehechen

Feature Request

Describe your feature request related problem

TiDB need to get region count between startKey and endKey from /pd/api/v1/stats/region to calculate TiFlash replica progress. GetRegionStatus will scan regions in BTree so it will have heavy cost if there are many regions.
In fact, TiDB only need region count, if /pd/api/v1/stats/region can add parameter to only get region count, the cost of /pd/api/v1/stats/region will reduce from O(N) to O(logN).

1 million regions, call /pd/api/v1/stats/region per 2 seconds, flame graph on PD:
7bae2d26-3aa0-43a9-b86f-dc7f79e39a7d

Describe the feature you'd like

Add a parameter in /pd/api/v1/stats/region to get only region count.

Describe alternatives you've considered

Teachability, Documentation, Adoption, Migration Strategy

Metadata

Metadata

Assignees

Labels

affects-6.1This bug affects the 6.1.x(LTS) versions.type/feature-requestCategorizes issue or PR as related to a new feature.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions