forked from lix-project/hydra
Merge pull request #969 from DeterminateSystems/builds-index-jobset-id
Builds: index on jobset_id, largely join by jobset_id
This commit is contained in:
commit
e04dc14d94
|
@ -81,26 +81,6 @@ sub build_GET {
|
|||
}
|
||||
}
|
||||
|
||||
if ($build->finished) {
|
||||
$c->stash->{prevBuilds} = [$c->model('DB::Builds')->search(
|
||||
{ project => $c->stash->{project}->name
|
||||
, jobset => $c->stash->{jobset}->name
|
||||
, job => $c->stash->{job}
|
||||
, 'me.system' => $build->system
|
||||
, finished => 1
|
||||
, buildstatus => 0
|
||||
, 'me.id' => { '<=' => $build->id }
|
||||
}
|
||||
, { join => "actualBuildStep"
|
||||
, "+select" => ["actualBuildStep.stoptime - actualBuildStep.starttime"]
|
||||
, "+as" => ["actualBuildTime"]
|
||||
, order_by => "me.id DESC"
|
||||
, rows => 50
|
||||
}
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
# Get the first eval of which this build was a part.
|
||||
($c->stash->{nrEvals}) = $build->jobsetevals->search({ hasnewbuilds => 1 })->count;
|
||||
$c->stash->{eval} = getFirstEval($build);
|
||||
|
|
|
@ -22,8 +22,7 @@ sub channel : Chained('/') PathPart('channel/custom') CaptureArgs(3) {
|
|||
|
||||
my $lastSuccessful = $c->model('DB::Builds')->find(
|
||||
{ 'eval.hasnewbuilds' => 1
|
||||
, project => $projectName
|
||||
, jobset => $jobsetName
|
||||
, jobset_id => $c->stash->{jobset}->id,
|
||||
, job => $channelName
|
||||
, buildstatus => 0
|
||||
},
|
||||
|
|
|
@ -64,8 +64,7 @@ sub getNextBuild {
|
|||
(my $nextBuild) = $c->model('DB::Builds')->search(
|
||||
{ finished => 1
|
||||
, system => $build->system
|
||||
, project => $build->get_column('project')
|
||||
, jobset => $build->get_column('jobset')
|
||||
, jobset_id => $build->get_column('jobset_id')
|
||||
, job => $build->get_column('job')
|
||||
, 'me.id' => { '>' => $build->id }
|
||||
}, {rows => 1, order_by => "me.id ASC"});
|
||||
|
@ -81,8 +80,7 @@ sub getPreviousSuccessfulBuild {
|
|||
(my $prevBuild) = $c->model('DB::Builds')->search(
|
||||
{ finished => 1
|
||||
, system => $build->system
|
||||
, project => $build->get_column('project')
|
||||
, jobset => $build->get_column('jobset')
|
||||
, jobset_id => $build->get_column('jobset_id')
|
||||
, job => $build->get_column('job')
|
||||
, buildstatus => 0
|
||||
, 'me.id' => { '<' => $build->id }
|
||||
|
|
|
@ -115,10 +115,10 @@ sub jobsetOverview_ {
|
|||
return $jobsets->search({},
|
||||
{ order_by => ["hidden ASC", "enabled DESC", "name"]
|
||||
, "+select" =>
|
||||
[ "(select count(*) from Builds as a where a.finished = 0 and me.project = a.project and me.name = a.jobset and a.isCurrent = 1)"
|
||||
, "(select count(*) from Builds as a where a.finished = 1 and me.project = a.project and me.name = a.jobset and buildstatus <> 0 and a.isCurrent = 1)"
|
||||
, "(select count(*) from Builds as a where a.finished = 1 and me.project = a.project and me.name = a.jobset and buildstatus = 0 and a.isCurrent = 1)"
|
||||
, "(select count(*) from Builds as a where me.project = a.project and me.name = a.jobset and a.isCurrent = 1)"
|
||||
[ "(select count(*) from Builds as a where me.id = a.jobset_id and a.finished = 0 and a.isCurrent = 1)"
|
||||
, "(select count(*) from Builds as a where me.id = a.jobset_id and a.finished = 1 and buildstatus <> 0 and a.isCurrent = 1)"
|
||||
, "(select count(*) from Builds as a where me.id = a.jobset_id and a.finished = 1 and buildstatus = 0 and a.isCurrent = 1)"
|
||||
, "(select count(*) from Builds as a where me.id = a.jobset_id and a.isCurrent = 1)"
|
||||
]
|
||||
, "+as" => ["nrscheduled", "nrfailed", "nrsucceeded", "nrtotal"]
|
||||
});
|
||||
|
|
|
@ -426,7 +426,7 @@ sub checkBuild {
|
|||
# semantically unnecessary (because they're implied by
|
||||
# the eval), but they give a factor 1000 speedup on
|
||||
# the Nixpkgs jobset with PostgreSQL.
|
||||
{ project => $jobset->get_column('project'), jobset => $jobset->name, job => $jobName,
|
||||
{ jobset_id => $jobset->get_column('id'), job => $jobName,
|
||||
name => $firstOutputName, path => $firstOutputPath },
|
||||
{ rows => 1, columns => ['id'], join => ['buildoutputs'] });
|
||||
if (defined $prevBuild) {
|
||||
|
|
|
@ -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);
|
||||
|
|
5
src/sql/upgrade-75.sql
Normal file
5
src/sql/upgrade-75.sql
Normal file
|
@ -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;
|
Loading…
Reference in a new issue