Commit d8145db
committed
perf(database): index PersonalAccessToken.userId so lookups stop seq-scanning
The two personal-access-token lookups filtered by userId (one also
filtering revokedAt, the other also filtering name) had no index on
userId, so each seq-scanned the whole table to return a single row.
userId is also an unindexed foreign key. Add @@index([userId]); a user
owns few PATs, so the single-column index serves both query shapes
without needing a composite. Migration uses CREATE INDEX CONCURRENTLY
IF NOT EXISTS.1 parent 7b7d489 commit d8145db
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