pingcap / pingcap/tidb

'show grants for user' become slow with the user count increasing

Open
#59,018 2 comments 0 reactions 0 assignees View on GitHub
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 ...

Image

### 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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.