avoid warmup startTS (TSO) prefetch for USE/SET to reduce PD load
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Enhancement
TiDB currently may prepare an async startTS future (TSO prefetch) during compile/warmup stage, even for statements that usually don't touch KV, e.g. `USE` and simple `SET`.
For workloads with lots of such statements, this causes unnecessary PD TSO requests.
Warmup happens before executor runs (compile stage) and is intended as an optimization. For `USE` / simple `SET`, prefetching TSO brings little to no benefit but increases PD load/QPS.
We should skip preparing the startTS future in warmup for these statement types, while still guaranteeing correctness:
- If a statement later truly needs TSO, it must still be fetched when the txn is activated / execution requires it (e.g. `SET @a=(SELECT ...)`).
Contributor guide
Assessment
This issue has not been assessed yet.