-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: enhance the table regions HTTP API #12357
Conversation
github.com/pingcap/pd v0.0.0-20190712044914-75a1f9f3062b h1:oS9PftxQqgcRouKhhdaB52tXhVLEP7Ng3Qqsd6Z18iY= | ||
github.com/pingcap/pd v0.0.0-20190712044914-75a1f9f3062b/go.mod h1:3DlDlFT7EF64A1bmb/tulZb6wbPSagm5G4p1AlhaEDs= | ||
github.com/pingcap/pd v1.1.0-beta.0.20190923032047-5c648dc365e0 h1:GIEq+wZfrl2bcJxpuSrEH4H7/nlf5YdmpS+dU9lNIt8= | ||
github.com/pingcap/pd v1.1.0-beta.0.20190923032047-5c648dc365e0/go.mod h1:G/6rJpnYwM0LKMec2rI82/5Kg6GaZMvlfB+e6/tvYmI= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird, any idea why it changes to v1.1.0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the latest pd in go.mod
https://github.com/pingcap/tidb/pull/12357/files#diff-37aff102a57d3d7b797f152915a6dc16R44
Codecov Report
@@ Coverage Diff @@
## master #12357 +/- ##
================================================
+ Coverage 79.7501% 80.1081% +0.3579%
================================================
Files 462 462
Lines 101917 103962 +2045
================================================
+ Hits 81279 83282 +2003
- Misses 14773 14818 +45
+ Partials 5865 5862 -3 |
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Your auto merge job has been accepted, waiting for 12348 |
/run-all-tests |
@tiancaiamao merge failed. |
/run-integration-common-test |
/merge |
/run-all-tests |
What problem does this PR solve?
This API is used to get the table regions http://localhost:10080/tables/{DB}/{Table}/regions
In current implementation,
getRegionsMeta
is used to get the region information.That function first gets the regions in the key range, and then call
GetRegionByID
one by one for each region id.The problem is that when the table is huge, it contains so many regions, calling the API is very slow because current implementation visits PD for each region.
What is changed and how it works?
Use
ScanRegions
API to implement http://localhost:10080/tables/{DB}/{Table}/regionsScanRegions accepts a key range and returns the region information, we need just one call to get the result instead of calling
GetRegionByID
for every region.See also tikv/pd#1700 tikv/pd#1699
Check List
Tests
I test it manually on TiKV.
Split the table to get more regions:
See the table regions:
Compare it with the result from the HTTP API: