From: Eric Bollengier Date: Tue, 19 May 2009 19:23:42 +0000 (+0000) Subject: ebl Speed up media list generation when using X-Git-Tag: Release-3.0.2~220 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7d8548d7ab10c7df17f0c67b5f056d95ed0fbb10;p=bacula%2Fbacula ebl Speed up media list generation when using "compute with directories" option git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8846 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/cgi/bresto.pl b/gui/bweb/cgi/bresto.pl index 3e590a63fb..e3bc0f5078 100755 --- a/gui/bweb/cgi/bresto.pl +++ b/gui/bweb/cgi/bresto.pl @@ -881,7 +881,7 @@ SELECT max(JobId) as JobId, PathId, FilenameId, FileIndex "(JobId, PathId, FilenameId)"); $bvfs->dbh_do("CREATE TABLE b2$$ AS ( -SELECT btemp.JobId, btemp.FileIndex, btemp.FilenameId, btemp.PathId $FileId +SELECT btemp.JobId, btemp.FileIndex $FileId FROM btemp, btemp2 WHERE btemp2.JobId = btemp.JobId AND btemp2.PathId= btemp.PathId @@ -902,6 +902,26 @@ FROM ( return "b2$$"; } +sub get_media_list_with_dir +{ + my ($table) = @_; + my $q=" + SELECT DISTINCT VolumeName, Enabled, InChanger + FROM $table, + ( -- Get all media from this job + SELECT MIN(FirstIndex) AS FirstIndex, MAX(LastIndex) AS LastIndex, + VolumeName, Enabled, Inchanger + FROM JobMedia JOIN Media USING (MediaId) + WHERE JobId IN (SELECT DISTINCT JobId FROM $table) + GROUP BY VolumeName,Enabled,InChanger + ) AS allmedia + WHERE $table.FileIndex >= allmedia.FirstIndex + AND $table.FileIndex <= allmedia.LastIndex +"; + my $lst = $bvfs->dbh_selectall_arrayref($q); + return $lst; +} + sub get_media_list { my ($jobid, $fileid) = @_; @@ -1059,6 +1079,7 @@ if ($action eq 'list_files') { # the media list that will be needed for restore } elsif ($action eq 'get_media') { my ($jobid, $fileid, $table); + my $lst; # in this mode, we compute the result to get all needed media if (CGI::param('force')) { @@ -1067,19 +1088,17 @@ if ($action eq 'list_files') { exit 1; } # mysql is very slow without this index... - if ($bvfs->dbh_is_mysql()) { - $bvfs->dbh_do("CREATE INDEX idx_$table ON $table (FileId)"); - } - $jobid = "SELECT DISTINCT JobId FROM $table"; - $fileid = "SELECT FileId FROM $table"; - +# if ($bvfs->dbh_is_mysql()) { +# $bvfs->dbh_do("CREATE INDEX idx_$table ON $table (FileId)"); +# } + $lst = get_media_list_with_dir($table); } else { $jobid = join(',', @jobid); $fileid = join(',', grep { /^\d+(,\d+)*$/ } CGI::param('fileid')); + $lst = get_media_list($jobid, $fileid); } - if ($jobid and $fileid) { - my $lst = get_media_list($jobid, $fileid); + if ($lst) { print "["; print join(',', map { "['$_->[0]',$_->[1],$_->[2]]" } @$lst); print "]\n"; diff --git a/gui/bweb/technotes-3.0 b/gui/bweb/technotes-3.0 index b2e54a2809..1c37c0dbf3 100644 --- a/gui/bweb/technotes-3.0 +++ b/gui/bweb/technotes-3.0 @@ -1,11 +1,14 @@ -15Apr09 +19May09 +ebl Speed up media list generation when using + "compute with directories" option +15May09 ebl speed up mysql to compute restore table ebl speed up mysql when computing media list ebl fix media list display ebl fix bresto problem with drag&drop -05Apr09 +05May09 ebl Make working the "compute with directories" option -04Apr09 +04May09 ebl Add View copies option to bresto ebl Tweak command output to add hide/display button 29Mar09