Use faster query to determine number of running builds
The previous query select count(*) from builds b left join buildsteps s on s.build = b.id where busy = 1 and finished = 0 is suddenly taking several minutes. Probably PostgreSQL decided to use a suboptimal query plan.
This commit is contained in:
parent
405a43c171
commit
520c8a5826
@ -45,9 +45,8 @@ sub begin :Private {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(@args) == 0 || $args[0] ne "static") {
|
if (scalar(@args) == 0 || $args[0] ne "static") {
|
||||||
$c->stash->{nrRunningBuilds} = $c->model('DB::Builds')->search(
|
$c->stash->{nrRunningBuilds} = $c->model('DB')->schema->storage->dbh->selectrow_array(
|
||||||
{ finished => 0, 'buildsteps.busy' => 1 },
|
"select count(distinct build) from buildsteps where busy = 1");
|
||||||
{ join => 'buildsteps', select => ["id"], distinct => 1 })->count();
|
|
||||||
$c->stash->{nrQueuedBuilds} = $c->model('DB::Builds')->search({ finished => 0 })->count();
|
$c->stash->{nrQueuedBuilds} = $c->model('DB::Builds')->search({ finished => 0 })->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user