From 72f0474f457073f3abd8e4a6fdc1e465fb1f50d6 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Tue, 30 Jun 2026 10:42:10 +0545 Subject: [PATCH] feat(src/tickets): add database indexes for performance Improve query speed on Ticket, TicketComment, and TicketPriority by indexing fields used in frequent filters and ordering. --- src/tickets/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tickets/models.py b/src/tickets/models.py index 7274761..8ac59a5 100644 --- a/src/tickets/models.py +++ b/src/tickets/models.py @@ -20,6 +20,9 @@ class TicketPriority(models.Model): db_table = "ticket_priorities" verbose_name = "Ticket Priority" verbose_name_plural = "Ticket Priorities" + indexes = [ + models.Index(fields=["name"]), + ] def __str__(self): return self.name @@ -103,6 +106,12 @@ class Ticket(models.Model): models.Index(fields=["due_date"]), models.Index(fields=["priority"]), models.Index(fields=["created_by"]), + models.Index(fields=["epic"]), + models.Index(fields=["name"]), + models.Index(fields=["start_date"]), + models.Index(fields=["project", "name"]), + models.Index(fields=["project", "start_date", "due_date"]), + models.Index(fields=["due_date", "status"]), ] def __str__(self): @@ -190,6 +199,7 @@ class TicketComment(models.Model): verbose_name_plural = "Ticket Comments" indexes = [ models.Index(fields=["ticket", "created_at"]), + models.Index(fields=["user"]), ] def __str__(self):