tikv / pd

Placement driver for TiKV
Apache License 2.0
1.03k stars 714 forks source link

Support `BatchScanRegions` which loads non-continuous regions in one RPC #8307

Closed you06 closed 1 week ago

you06 commented 1 week ago

Development Task

Sometimes, the client need to locate non-continuous key ranges. Current PD has no good solution for this requirement.

There are 2 workaround:

  1. Use GetRegion to load region one by one, check if the ranges are drained eachtime.
  2. Use ScanRegion to load (ranges[0].start, ranges[len(ranges)-1].end), which can cause unexpected traffics (imagine the ranges[0] is the first row and ranges[len(ranges)-1] is the last row of a large table).

Thus a interface BatchScanRegions is required.

It returns multi regions like ScanRegion, but accept a key range slice parameters. The returned regions are guaranteed to cover the given ranges if limitation is not reached.