From 924c30bac4fb95176230ab1007643b66e9474beb Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Fri, 20 Nov 2026 17:06:33 +0000 Subject: [PATCH] Add indexes for active builds and build history --- utils/database-indexes.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 utils/database-indexes.sql diff --git a/utils/database-indexes.sql b/utils/database-indexes.sql new file mode 100644 index 00000000..fec87cf2 --- /dev/null +++ b/utils/database-indexes.sql @@ -0,0 +1,11 @@ +\set ON_ERROR_STOP on +\timing on + +-- Run with psql against the Buildbot database, outside a transaction block. +-- These indexes support active builds, builder history, and worker history. +CREATE INDEX CONCURRENTLY IF NOT EXISTS builds_incomplete_id + ON builds (id) WHERE complete_at IS NULL; +CREATE INDEX CONCURRENTLY IF NOT EXISTS builds_builderid_complete_at + ON builds (builderid, complete_at DESC); +CREATE INDEX CONCURRENTLY IF NOT EXISTS builds_workerid_started_at + ON builds (workerid, started_at DESC);