Use delete instead of delete_all

DBIC's delete_all method fetches all rows separately, which is slow.
This commit is contained in:
Eelco Dolstra 2013-10-03 19:42:44 +02:00
parent f32077b5e8
commit 720c3892a3
8 changed files with 15 additions and 23 deletions

View file

@ -53,19 +53,11 @@ sub clearfailedcache : Chained('admin') PathPart('clear-failed-cache') Args(0) {
sub clearvcscache : Chained('admin') PathPart('clear-vcs-cache') Args(0) {
my ($self, $c) = @_;
print STDERR "Clearing path cache\n";
$c->model('DB::CachedPathInputs')->delete_all;
print STDERR "Clearing git cache\n";
$c->model('DB::CachedGitInputs')->delete_all;
print STDERR "Clearing subversion cache\n";
$c->model('DB::CachedSubversionInputs')->delete_all;
print STDERR "Clearing bazaar cache\n";
$c->model('DB::CachedBazaarInputs')->delete_all;
$c->model('DB::CachedPathInputs')->delete;
$c->model('DB::CachedGitInputs')->delete;
$c->model('DB::CachedSubversionInputs')->delete;
$c->model('DB::CachedBazaarInputs')->delete;
$c->flash->{successMsg} = "VCS caches have been cleared.";
$c->res->redirect($c->request->referer // "/admin");
}

View file

@ -78,8 +78,8 @@ sub jobset_DELETE {
requireProjectOwner($c, $c->stash->{project});
txn_do($c->model('DB')->schema, sub {
$c->stash->{jobset}->jobsetevals->delete_all;
$c->stash->{jobset}->builds->delete_all;
$c->stash->{jobset}->jobsetevals->delete;
$c->stash->{jobset}->builds->delete;
$c->stash->{jobset}->delete;
});

View file

@ -88,8 +88,8 @@ sub project_DELETE {
requireProjectOwner($c, $c->stash->{project});
txn_do($c->model('DB')->schema, sub {
$c->stash->{project}->jobsetevals->delete_all;
$c->stash->{project}->builds->delete_all;
$c->stash->{project}->jobsetevals->delete;
$c->stash->{project}->builds->delete;
$c->stash->{project}->delete;
});

View file

@ -38,7 +38,7 @@ sub updateRelease {
, description => trim $c->request->params->{description}
});
$release->releasemembers->delete_all;
$release->releasemembers->delete;
foreach my $param (keys %{$c->request->params}) {
next unless $param =~ /^member-(\d+)-description$/;
my $buildId = $1;

View file

@ -254,7 +254,7 @@ sub edit_POST {
}
if (isAdmin($c)) {
$user->userroles->delete_all;
$user->userroles->delete;
$user->userroles->create({ role => $_})
foreach paramToList($c, "roles");
}

View file

@ -41,7 +41,7 @@ sub updateView {
{ name => $viewName
, description => trim $c->request->params->{description} });
$view->viewjobs->delete_all;
$view->viewjobs->delete;
foreach my $param (keys %{$c->request->params}) {
next unless $param =~ /^job-(\d+)-name$/;

View file

@ -570,7 +570,7 @@ sub restartBuild {
, iscachedbuild => 0
});
$build->buildproducts->delete_all;
$build->buildproducts->delete;
# Reset the stats for the evals to which this build belongs.
# !!! Should do this in a trigger.

View file

@ -354,8 +354,8 @@ txn_do($db, sub {
die "build $buildId is already being built";
}
$build->update({busy => 1, locker => $$});
$build->buildsteps->search({busy => 1})->delete_all;
$build->buildproducts->delete_all;
$build->buildsteps->search({busy => 1})->delete;
$build->buildproducts->delete;
});
die unless $build;