diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 4c8710b8..a39d9aac 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -688,3 +688,9 @@ create index IndexBuildsOnKeep on Builds(keep) where keep = 1; create index IndexJobsetEvalsOnJobsetId on JobsetEvals(project, jobset, id desc) where hasNewBuilds = 1; create index IndexBuildsOnNotificationPendingSince on Builds(notificationPendingSince) where notificationPendingSince is not null; + +#ifdef POSTGRESQL +-- Provide an index used by LIKE operator on builds.drvpath (search query) +CREATE EXTENSION pg_trgm; +CREATE INDEX IndexTrgmBuildsOnDrvpath ON builds USING gin (drvpath gin_trgm_ops); +#endif diff --git a/src/sql/upgrade-57.sql b/src/sql/upgrade-57.sql new file mode 100644 index 00000000..f950a6e0 --- /dev/null +++ b/src/sql/upgrade-57.sql @@ -0,0 +1,2 @@ +CREATE EXTENSION pg_trgm; +CREATE INDEX IndexTrgmBuildsOnDrvpath ON builds USING gin (drvpath gin_trgm_ops);