* 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);
$c->stash->{activeJobs} = [
$c->stash->{jobset}->builds->search(
{isCurrent => 1},
{select => ["job"], order_by => ["job"], distinct => 1}
)];
$c->stash->{inactiveJobs} = [
$c->stash->{jobset}->builds->search(
{},
{select => ["job"], order_by => ["job"], group_by => ["job"], having => { 'sum(isCurrent)' => 0 }}
)];
my $projectName = $c->stash->{project}->name;
my $jobsetName = $c->stash->{jobset}->name;
# Get the active / inactive jobs in this jobset.
my @jobs = $c->stash->{jobset}->jobs->search(
{ },
{ select => [
"name",
\("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})];
# 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(@as, $system."-build");
}
$c->stash->{activeJobsStatus} = [$c->model('DB')->resultset('ActiveJobsForJobset')
->search( {}
, { bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]
$c->stash->{activeJobsStatus} =
[ $c->model('DB')->resultset('ActiveJobsForJobset')->search(
{},
{ bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]
, select => \@select
, as => \@as
, order_by => ["job"]

View file

@ -238,7 +238,7 @@
<blockquote>
[% 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>
</p>
@ -246,7 +246,7 @@
<blockquote>
[% 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>
</p>

View file

@ -422,20 +422,22 @@ create table JobsetInputHashes (
-- Some indices.
create index IndexBuildInputsByBuild on BuildInputs(build);
create index IndexBuildInputsByDependency on BuildInputs(dependency);
create index IndexBuildsByTimestamp on Builds(timestamp);
create index IndexBuildsByIsCurrent on Builds(isCurrent);
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 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 IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL
create index IndexBuildSchedulingInfoByBuild on BuildSchedulingInfo(id); -- idem
create index IndexBuildProductsByBuild on BuildProducts(build);
create index IndexBuildProducstByBuildAndType on BuildProducts(build, type);
create index IndexBuildStepsByBuild on BuildSteps(build);
create index IndexBuildSchedulingInfoOnBuild on BuildSchedulingInfo(id); -- idem
create index IndexBuildStepsOnBuild on BuildSteps(build);
create index IndexBuildsOnFinished on Builds(finished);
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