-- Execute outside a transaction, using a pinned connection with bounded timeouts. -- Measured against two isolated copies of production data; no source row rewrite. CREATE INDEX CONCURRENTLY IF NOT EXISTS xs_history_report_lesson ON "LessonCompletionReport"(company,"lessonId","submittedAt" DESC); CREATE INDEX CONCURRENTLY IF NOT EXISTS xs_history_report_appointment ON "LessonCompletionReport"(company,("appointmentGeneralId"::text),"submittedAt" DESC); CREATE INDEX CONCURRENTLY IF NOT EXISTS xs_history_review_student ON "MemoryPracticeRecord"(company,(yhid::text),"objectId"); CREATE INDEX CONCURRENTLY IF NOT EXISTS xs_history_user_legacy ON "_User"((company::text),("legacyUserId"::text),"objectId");