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