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:
Eelco Dolstra
2014-09-29 23:03:38 +02:00
parent 773c7e89cf
commit d9a5143fcb
2 changed files with 25 additions and 8 deletions

17
src/sql/upgrade-30.sql Normal file
View 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;