Commit b10055b
committed
perf(database): index PersonalAccessToken.userId so token lookups stop seq-scanning
Both PAT-by-user lookups (userId + revokedAt is null, and userId + name)
had no index on userId and seq-scanned the whole table, reading ~44k-47k
rows to return ~1. userId is also an unindexed foreign key. Add @@index
([userId]); a user owns few PATs so the single-column index serves both
query shapes.
Seeded local EXPLAIN (50k rows): Seq Scan -> Index Scan on both queries,
shared buffers 689 pages -> 3.1 parent 7b7d489 commit b10055b
3 files changed
Lines changed: 9 additions & 0 deletions
File tree
- .server-changes
- internal-packages/database/prisma
- migrations/20260812140000_add_personal_access_token_user_id_index
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
158 | 160 | | |
159 | 161 | | |
160 | 162 | | |
| |||
0 commit comments