From a9e4ede006e35c83db39f071cb8b672b518e26a3 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 1 Jun 2021 11:23:22 -0400 Subject: [PATCH] SQL: create better indexes for builds based on the jobset id These are primarily used by the jobsetOverview renders. --- src/sql/hydra.sql | 3 +++ src/sql/upgrade-75.sql | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 src/sql/upgrade-75.sql diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index a73da0fb..c664d854 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -612,6 +612,9 @@ create index IndexBuildsOnFinished on Builds(finished) where finished = 0; create index IndexBuildsOnIsCurrent on Builds(isCurrent) where isCurrent = 1; create index IndexBuildsOnJobsetIsCurrent on Builds(project, jobset, isCurrent) where isCurrent = 1; create index IndexBuildsOnJobIsCurrent on Builds(project, jobset, job, isCurrent) where isCurrent = 1; +create index IndexBuildsJobsetIdCurrentUnfinished on Builds(jobset_id) where isCurrent = 1 and finished = 0; +create index IndexBuildsJobsetIdCurrentFinishedStatus on Builds(jobset_id, buildstatus) where isCurrent = 1 and finished = 1; +create index IndexBuildsJobsetIdCurrent on Builds(jobset_id) where isCurrent = 1; create index IndexBuildsOnJobset on Builds(project, jobset); create index IndexBuildsOnProject on Builds(project); create index IndexBuildsOnTimestamp on Builds(timestamp); diff --git a/src/sql/upgrade-75.sql b/src/sql/upgrade-75.sql new file mode 100644 index 00000000..ba0e7dbd --- /dev/null +++ b/src/sql/upgrade-75.sql @@ -0,0 +1,5 @@ +-- These take about 9 minutes in total on a replica of hydra.nixos.org + +create index IndexBuildsJobsetIdCurrentUnfinished on Builds(jobset_id) where isCurrent = 1 and finished = 0; +create index IndexBuildsJobsetIdCurrentFinishedStatus on Builds(jobset_id, buildstatus) where isCurrent = 1 and finished = 1; +create index IndexBuildsJobsetIdCurrent on Builds(jobset_id) where isCurrent = 1;