From 86498ec0df35b7ed94548f7bd90a037649e5d29f Mon Sep 17 00:00:00 2001 From: Kaj Kowalski Date: Sat, 28 Jun 2025 21:18:11 +0200 Subject: [PATCH] perf: add missing indexes for session filtering and sorting - Add compound index on (companyId, language) for language filtering - Add compound index on (companyId, messagesSent) for message count sorting - Add compound index on (companyId, avgResponseTime) for response time sorting These indexes optimize the session dashboard queries that filter by language or sort by messagesSent/avgResponseTime, preventing full table scans. --- prisma/schema.prisma | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8160c25..dc26bbf 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -147,6 +147,9 @@ model Session { @@index([companyId, category]) @@index([companyId, escalated]) @@index([companyId, forwardedHr]) + @@index([companyId, language]) + @@index([companyId, messagesSent]) + @@index([companyId, avgResponseTime]) } /// *