Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
139191: sql: add fast-path to maybeParallelizeLocalScans r=yuzefovich a=yuzefovich `maybeParallelizeLocalScans` is responsible for deciding whether we want to plan multiple TableReaders on the gateway to serve one set of key spans. This is needed to power the lookup into remote regions in parallel with locality optimized search. By construction, we will only plan multiple TableReaders if the set of key spans touches multiple ranges, so this commit introduces a quick check to see whether we have at least two ranges involved, and if not, then we can skip a somewhat heavy `PartitionSpans` call. I temporarily added `SELECT k, v FROM kv WHERE k IN (1, 3)` "kv-read-two" query to `BenchmarkEndToEnd` to highlight the improvement: ``` name old time/op new time/op delta EndToEnd/kv-read-two/vectorize=on/Simple-24 431µs ± 2% 420µs ± 2% -2.44% (p=0.000 n=10+10) EndToEnd/kv-read-two/vectorize=on/Prepared-24 295µs ± 2% 289µs ± 2% -2.12% (p=0.001 n=10+10) EndToEnd/kv-read-two/vectorize=off/Simple-24 408µs ± 2% 411µs ± 3% ~ (p=0.280 n=10+10) EndToEnd/kv-read-two/vectorize=off/Prepared-24 278µs ± 2% 279µs ± 2% ~ (p=0.447 n=10+9) name old alloc/op new alloc/op delta EndToEnd/kv-read-two/vectorize=on/Prepared-24 30.1kB ± 0% 27.9kB ± 1% -7.07% (p=0.000 n=10+10) EndToEnd/kv-read-two/vectorize=on/Simple-24 43.7kB ± 1% 41.5kB ± 0% -4.98% (p=0.000 n=10+9) EndToEnd/kv-read-two/vectorize=off/Simple-24 40.6kB ± 0% 40.6kB ± 1% ~ (p=0.399 n=9+9) EndToEnd/kv-read-two/vectorize=off/Prepared-24 28.9kB ± 0% 29.0kB ± 0% ~ (p=0.781 n=10+10) name old allocs/op new allocs/op delta EndToEnd/kv-read-two/vectorize=on/Prepared-24 243 ± 0% 230 ± 0% -5.19% (p=0.000 n=8+10) EndToEnd/kv-read-two/vectorize=on/Simple-24 346 ± 0% 334 ± 0% -3.58% (p=0.000 n=6+10) EndToEnd/kv-read-two/vectorize=off/Simple-24 315 ± 0% 315 ± 0% ~ (p=1.210 n=10+9) EndToEnd/kv-read-two/vectorize=off/Prepared-24 223 ± 0% 223 ± 0% ~ (all equal) ``` Note that `vectorize=off` setup is unaffected because the parallelize local scans feature is disabled when we use row-by-row engine. Epic: None Release note: None Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
- Loading branch information