From: Eric Bollengier Date: Wed, 27 May 2009 07:08:00 +0000 (+0000) Subject: ebl Simplify mysql bresto part. Should be faster, but need tests X-Git-Tag: Release-3.0.2~199 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=15970f33e3f72a2dc352acd3c3dcc87358d12d3f;p=bacula%2Fbacula ebl Simplify mysql bresto part. Should be faster, but need tests git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8867 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/cgi/bresto.pl b/gui/bweb/cgi/bresto.pl index e3bc0f5078..abb5bea038 100755 --- a/gui/bweb/cgi/bresto.pl +++ b/gui/bweb/cgi/bresto.pl @@ -871,23 +871,13 @@ sub fill_table_for_restore # now we have to choose the file with the max(jobid) # for each file of btemp if ($bvfs->dbh_is_mysql()) { - $bvfs->dbh_do("CREATE TEMPORARY TABLE btemp2 AS ( -SELECT max(JobId) as JobId, PathId, FilenameId, FileIndex + $bvfs->dbh_do("CREATE TABLE b2$$ AS ( +SELECT max(JobId) as JobId, FileIndex $FileId FROM btemp GROUP BY PathId, FilenameId HAVING FileIndex > 0 )"); - $bvfs->dbh_do("CREATE INDEX btemp2_idx ON btemp2 " . - "(JobId, PathId, FilenameId)"); - - $bvfs->dbh_do("CREATE TABLE b2$$ AS ( -SELECT btemp.JobId, btemp.FileIndex $FileId - FROM btemp, btemp2 - WHERE btemp2.JobId = btemp.JobId - AND btemp2.PathId= btemp.PathId - AND btemp2.FilenameId = btemp.FilenameId -)"); - } else { # postgresql have distinct with more than one criteria... + } else { # postgresql have distinct with more than one criteria $bvfs->dbh_do("CREATE TABLE b2$$ AS ( SELECT JobId, FileIndex $FileId FROM ( @@ -1088,9 +1078,9 @@ 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)"); -# } + if ($bvfs->dbh_is_mysql()) { + $bvfs->dbh_do("CREATE INDEX idx_$table ON $table (JobId)"); + } $lst = get_media_list_with_dir($table); } else { $jobid = join(',', @jobid);