'show grants for user' become slow with the user count increasing
Open
sig/sql-infra
type/enhancement
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
create 2M users, and the call 'show grants for userxxx' , the qps drop with the test going ...
### 2. What did you expect to see? (Required)
'show grants for user' operation should be O(1) or O(logN) where N is the user count.
### 3. What did you see instead (Required)
It's a O(N) operation and not scale well when the user count increase.
https://github.com/pingcap/tidb/blob/365a722c4d10c76326f91eac2fad1d7267f24f4e/pkg/privilege/privileges/cache.go#L1531-L1543
### 4. What is your TiDB version? (Required)
Contributor guide
Assessment
This issue has not been assessed yet.