forked from lix-project/hydra
Use partial indexes
There is no point in indexing rows with common column values like "finished = 1", since those are the majority of the table. Only the exceptions ("finished = 0") are interesting. Having smaller tables should make updates/insertions faster.
This commit is contained in:
parent
773c7e89cf
commit
d9a5143fcb
|
@ -541,14 +541,14 @@ create index IndexBuildInputsOnBuild on BuildInputs(build);
|
|||
create index IndexBuildInputsOnDependency on BuildInputs(dependency);
|
||||
create index IndexBuildProducstOnBuildAndType on BuildProducts(build, type);
|
||||
create index IndexBuildProductsOnBuild on BuildProducts(build);
|
||||
create index IndexBuildStepsOnBusy on BuildSteps(busy);
|
||||
create index IndexBuildStepsOnDrvpathTypeBusyStatus on BuildSteps(drvpath, type, busy, status);
|
||||
create index IndexBuildStepsOnBusy on BuildSteps(busy) where busy = 1;
|
||||
create index IndexBuildStepsOnDrvPath on BuildSteps(drvpath);
|
||||
create index IndexBuildStepOutputsOnPath on BuildStepOutputs(path);
|
||||
create index IndexBuildsOnFinished on Builds(finished);
|
||||
create index IndexBuildsOnFinishedBusy on Builds(finished, busy);
|
||||
create index IndexBuildsOnIsCurrent on Builds(isCurrent);
|
||||
create index IndexBuildsOnJobsetIsCurrent on Builds(project, jobset, isCurrent);
|
||||
create index IndexBuildsOnJobIsCurrent on Builds(project, jobset, job, isCurrent);
|
||||
create index IndexBuildsOnFinished on Builds(finished) where finished = 0;
|
||||
create index IndexBuildsOnFinishedBusy on Builds(finished, busy) 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 IndexBuildsOnJobset on Builds(project, jobset);
|
||||
create index IndexBuildsOnProject on Builds(project);
|
||||
create index IndexBuildsOnTimestamp on Builds(timestamp);
|
||||
|
@ -567,7 +567,7 @@ create index IndexProjectsOnEnabled on Projects(enabled);
|
|||
create index IndexReleaseMembersOnBuild on ReleaseMembers(build);
|
||||
|
||||
-- For hydra-update-gc-roots.
|
||||
create index IndexBuildsOnKeep on Builds(keep);
|
||||
create index IndexBuildsOnKeep on Builds(keep) where keep = 1;
|
||||
|
||||
-- To get the most recent eval for a jobset.
|
||||
create index IndexJobsetEvalsOnJobsetId on JobsetEvals(project, jobset, hasNewBuilds, id desc);
|
||||
|
|
17
src/sql/upgrade-30.sql
Normal file
17
src/sql/upgrade-30.sql
Normal file
|
@ -0,0 +1,17 @@
|
|||
drop index IndexBuildStepsOnBusy;
|
||||
drop index IndexBuildStepsOnDrvpathTypeBusyStatus;
|
||||
drop index IndexBuildsOnFinished;
|
||||
drop index IndexBuildsOnFinishedBusy;
|
||||
drop index IndexBuildsOnIsCurrent;
|
||||
drop index IndexBuildsOnJobsetIsCurrent;
|
||||
drop index IndexBuildsOnJobIsCurrent;
|
||||
drop index IndexBuildsOnKeep;
|
||||
|
||||
create index IndexBuildStepsOnBusy on BuildSteps(busy) where busy = 1;
|
||||
create index IndexBuildStepsOnDrvPath on BuildSteps(drvpath);
|
||||
create index IndexBuildsOnFinished on Builds(finished) where finished = 0;
|
||||
create index IndexBuildsOnFinishedBusy on Builds(finished, busy) 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 IndexBuildsOnKeep on Builds(keep) where keep = 1;
|
Loading…
Reference in a new issue