1-- TASK-0135 perf hot-path indexes (EXPLAIN-proven; see docs/development/perf-report.md). 2-- Plain CREATE INDEX IF NOT EXISTS (transaction-safe under Prisma migrate; the two 3-- historical CONCURRENTLY entries were hand-applied out-of-band). 4 5-- Audit-listing query: 6-- SELECT * FROM audit_logs WHERE "workspaceId" = $1 ORDER BY "createdAt" DESC LIMIT 50 7-- Before: Seq Scan + explicit Sort. The existing audit_logs_workspaceId_action_createdAt_idx 8-- is NOT usable for a workspace-wide listing (its 2nd key is `action`, so a 9-- workspace-prefixed range with no action predicate cannot scan it in createdAt order). 10-- After: backward Index Scan on (workspaceId, createdAt DESC), the Sort node disappears. 11CREATE INDEX IF NOT EXISTS "audit_logs_workspaceId_createdAt_idx" 12 ON "audit_logs" ("workspaceId", "createdAt" DESC); 13 14-- File-listing query: 15-- SELECT * FROM files WHERE "workspaceId" = $1 AND "deletedAt" IS NULL ORDER BY "createdAt" DESC LIMIT 50 16-- Before: Seq Scan + Sort (the existing files_workspaceId_deletedAt_idx cannot serve the 17-- createdAt ordering). "deletedAt" IS NULL is low-selectivity, so the index is on 18-- (workspaceId, createdAt DESC) and the NULL filter is applied as a recheck. 19CREATE INDEX IF NOT EXISTS "files_workspaceId_createdAt_idx" 20 ON "files" ("workspaceId", "createdAt" DESC); 21