From 67562856d3564dcc763732062905aec0485b638c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 13 Jun 2022 12:30:11 +0200 Subject: [PATCH] Manager: let Gorm create an index on `Task.LastTouchedAt` It's used in timeout queries, and there could be tens or hundreds of thousands of tasks in the database. --- internal/manager/persistence/jobs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/manager/persistence/jobs.go b/internal/manager/persistence/jobs.go index 80b7d240..4f02d256 100644 --- a/internal/manager/persistence/jobs.go +++ b/internal/manager/persistence/jobs.go @@ -46,7 +46,7 @@ type Task struct { // Which worker is/was working on this. WorkerID *uint Worker *Worker `gorm:"foreignkey:WorkerID;references:ID;constraint:OnDelete:CASCADE"` - LastTouchedAt time.Time // Should contain UTC timestamps. + LastTouchedAt time.Time `gorm:"index"` // Should contain UTC timestamps. // Dependencies are tasks that need to be completed before this one can run. Dependencies []*Task `gorm:"many2many:task_dependencies;constraint:OnDelete:CASCADE"`