From 720c3892a36ad96c67539f6a73484ddb755d89cf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 3 Oct 2013 19:42:44 +0200 Subject: [PATCH] Use delete instead of delete_all DBIC's delete_all method fetches all rows separately, which is slow. --- src/lib/Hydra/Controller/Admin.pm | 18 +++++------------- src/lib/Hydra/Controller/Jobset.pm | 4 ++-- src/lib/Hydra/Controller/Project.pm | 4 ++-- src/lib/Hydra/Controller/Release.pm | 2 +- src/lib/Hydra/Controller/User.pm | 2 +- src/lib/Hydra/Controller/View.pm | 2 +- src/lib/Hydra/Helper/AddBuilds.pm | 2 +- src/script/hydra-build | 4 ++-- 8 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/lib/Hydra/Controller/Admin.pm b/src/lib/Hydra/Controller/Admin.pm index d533ed5c..f2a34459 100644 --- a/src/lib/Hydra/Controller/Admin.pm +++ b/src/lib/Hydra/Controller/Admin.pm @@ -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"); } diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 0dfa824b..e0d5ee83 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -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; }); diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index 09d9bb7e..8a7f39da 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -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; }); diff --git a/src/lib/Hydra/Controller/Release.pm b/src/lib/Hydra/Controller/Release.pm index 5007fdec..a4fb61c9 100644 --- a/src/lib/Hydra/Controller/Release.pm +++ b/src/lib/Hydra/Controller/Release.pm @@ -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; diff --git a/src/lib/Hydra/Controller/User.pm b/src/lib/Hydra/Controller/User.pm index 84ec88df..e4f0ecc4 100644 --- a/src/lib/Hydra/Controller/User.pm +++ b/src/lib/Hydra/Controller/User.pm @@ -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"); } diff --git a/src/lib/Hydra/Controller/View.pm b/src/lib/Hydra/Controller/View.pm index 1f8f7847..88e78cb5 100644 --- a/src/lib/Hydra/Controller/View.pm +++ b/src/lib/Hydra/Controller/View.pm @@ -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$/; diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index b9d7a297..1a575e66 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -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. diff --git a/src/script/hydra-build b/src/script/hydra-build index 72968930..edd0d121 100755 --- a/src/script/hydra-build +++ b/src/script/hydra-build @@ -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;