* Speed up the jobset index page. Especially the query to get the

inactive jobs was quite slow.
* "IndexBy" -> "IndexOn".
This commit is contained in:
Eelco Dolstra 2010-02-09 13:47:20 +00:00
parent 4abdf86bd4
commit 59e4f65298
3 changed files with 60 additions and 43 deletions

View file

@ -27,16 +27,30 @@ sub jobsetIndex {
#getBuildStats($c, scalar $c->stash->{jobset}->builds); #getBuildStats($c, scalar $c->stash->{jobset}->builds);
$c->stash->{activeJobs} = [ my $projectName = $c->stash->{project}->name;
$c->stash->{jobset}->builds->search( my $jobsetName = $c->stash->{jobset}->name;
{isCurrent => 1},
{select => ["job"], order_by => ["job"], distinct => 1} # Get the active / inactive jobs in this jobset.
)]; my @jobs = $c->stash->{jobset}->jobs->search(
$c->stash->{inactiveJobs} = [ { },
$c->stash->{jobset}->builds->search( { select => [
{}, "name",
{select => ["job"], order_by => ["job"], group_by => ["job"], having => { 'sum(isCurrent)' => 0 }} \("exists (select 1 from builds where project = '$projectName' and jobset = '$jobsetName' and job = me.name and isCurrent = 1) as active")
)]; ]
, as => ["name", "active"]
, order_by => ["name"] });
$c->stash->{activeJobs} = [];
$c->stash->{inactiveJobs} = [];
foreach my $job (@jobs) {
print STDERR $job->get_column('active'), "\n";
if ($job->get_column('active')) {
push @{$c->stash->{activeJobs}}, $job->name;
} else {
push @{$c->stash->{inactiveJobs}}, $job->name;
}
}
$c->stash->{systems} = [$c->stash->{jobset}->builds->search({iscurrent => 1}, {select => ["system"], distinct => 1})]; $c->stash->{systems} = [$c->stash->{jobset}->builds->search({iscurrent => 1}, {select => ["system"], distinct => 1})];
# status per system # status per system
@ -55,9 +69,10 @@ sub jobsetIndex {
push(@select, "(SELECT b.id FROM BuildResultInfo bri NATURAL JOIN Builds b WHERE b.id = (SELECT MAX(id) FROM Builds t WHERE t.project = me.project AND t.jobset = me.jobset AND t.job = me.job AND t.system = '$system'))"); push(@select, "(SELECT b.id FROM BuildResultInfo bri NATURAL JOIN Builds b WHERE b.id = (SELECT MAX(id) FROM Builds t WHERE t.project = me.project AND t.jobset = me.jobset AND t.job = me.job AND t.system = '$system'))");
push(@as, $system."-build"); push(@as, $system."-build");
} }
$c->stash->{activeJobsStatus} = [$c->model('DB')->resultset('ActiveJobsForJobset') $c->stash->{activeJobsStatus} =
->search( {} [ $c->model('DB')->resultset('ActiveJobsForJobset')->search(
, { bind => [$c->stash->{project}->name, $c->stash->{jobset}->name] {},
{ bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]
, select => \@select , select => \@select
, as => \@as , as => \@as
, order_by => ["job"] , order_by => ["job"]

View file

@ -238,7 +238,7 @@
<blockquote> <blockquote>
[% IF activeJobs.size == 0 %]<em>(none)</em>[% END %] [% IF activeJobs.size == 0 %]<em>(none)</em>[% END %]
[% FOREACH j IN activeJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j.get_column('job') %] [% END %] [% FOREACH j IN activeJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %] [% END %]
</blockquote> </blockquote>
</p> </p>
@ -246,7 +246,7 @@
<blockquote> <blockquote>
[% IF inactiveJobs.size == 0 %]<em>(none)</em>[% END %] [% IF inactiveJobs.size == 0 %]<em>(none)</em>[% END %]
[% FOREACH j IN inactiveJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j.get_column('job') %] [% END %] [% FOREACH j IN inactiveJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %] [% END %]
</blockquote> </blockquote>
</p> </p>

View file

@ -422,20 +422,22 @@ create table JobsetInputHashes (
-- Some indices. -- Some indices.
create index IndexBuildInputsByBuild on BuildInputs(build); create index IndexBuildInputsOnBuild on BuildInputs(build);
create index IndexBuildInputsByDependency on BuildInputs(dependency); create index IndexBuildInputsOnDependency on BuildInputs(dependency);
create index IndexBuildsByTimestamp on Builds(timestamp); create index IndexBuildProducstOnBuildAndType on BuildProducts(build, type);
create index IndexBuildsByIsCurrent on Builds(isCurrent); create index IndexBuildProductsOnBuild on BuildProducts(build);
create index IndexBuildsByFinished on Builds(finished);
create index IndexBuildsByProject on Builds(project);
create index IndexBuildsByJobset on Builds(project, jobset);
create index IndexBuildsByJob on Builds(project, jobset, job);
create index IndexBuildsByJobAndSystem on Builds(project, jobset, job, system);
create index IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL create index IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL
create index IndexBuildSchedulingInfoByBuild on BuildSchedulingInfo(id); -- idem create index IndexBuildSchedulingInfoOnBuild on BuildSchedulingInfo(id); -- idem
create index IndexBuildProductsByBuild on BuildProducts(build); create index IndexBuildStepsOnBuild on BuildSteps(build);
create index IndexBuildProducstByBuildAndType on BuildProducts(build, type); create index IndexBuildsOnFinished on Builds(finished);
create index IndexBuildStepsByBuild on BuildSteps(build); create index IndexBuildsOnIsCurrent on Builds(isCurrent);
create index IndexBuildsOnJob on Builds(project, jobset, job);
create index IndexBuildsOnJobAndIsCurrent on Builds(project, jobset, job, isCurrent);
create index IndexBuildsOnJobAndSystem on Builds(project, jobset, job, system);
create index IndexBuildsOnJobset on Builds(project, jobset);
create index IndexBuildsOnProject on Builds(project);
create index IndexBuildsOnTimestamp on Builds(timestamp);
create index IndexJobsetAltsOnJobset on JobsetInputAlts(project, jobset);
#ifdef SQLITE #ifdef SQLITE