| 1 | -- Indexes for D1 queries that scanned whole tables as they grew (scalability evaluation, 2026-10-14). |
| 2 | -- Suspended people, read on every issue and pull request page (lib/moderation.ts suspendedIds). |
| 3 | CREATE INDEX IF NOT EXISTS accounts_suspended ON accounts(suspended_at) WHERE suspended_at IS NOT NULL; |
| 4 | -- Pending invitations by address, read at every sign-up and sign-in (lib/directory.ts). |
| 5 | CREATE INDEX IF NOT EXISTS invites_email ON invites(email); |
| 6 | -- An owner's imports in progress (lib/directory.ts), and the cron that expires drafts. |
| 7 | CREATE INDEX IF NOT EXISTS imports_target_owner ON imports(target_owner_id, status); |
| 8 | CREATE INDEX IF NOT EXISTS imports_status ON imports(status, created_at); |
| 9 | -- Token expiry reminders (mail/notify.ts mailCron, every five minutes). |
| 10 | CREATE INDEX IF NOT EXISTS tokens_expires ON tokens(expires_at); |
| 11 | -- Container registry cleanup (registry/store.ts, every five minutes). |
| 12 | CREATE INDEX IF NOT EXISTS registry_blobs_created ON registry_blobs(created_at); |
| 13 | CREATE INDEX IF NOT EXISTS package_blobs_created ON package_blobs(created_at); |
| 14 | -- Retention (lib/retention.ts): expired sessions and old notifications are deleted. |
| 15 | CREATE INDEX IF NOT EXISTS sessions_expires ON sessions(expires_at); |
| 16 | CREATE INDEX IF NOT EXISTS notifications_created ON notifications(created_at); |