From: Eric Bollengier Date: Tue, 8 Jul 2008 11:15:32 +0000 (+0000) Subject: ebl Add a sort to db_get_file_list to improve X-Git-Tag: Release-3.0.0~1175 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c4738462c0b1bb44c790c5bdd7117c4db5fe6fbe;p=bacula%2Fbacula ebl Add a sort to db_get_file_list to improve bsr construction time. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7340 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index c0fbb3f5bc..468c9e628e 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -1022,10 +1022,7 @@ bool db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) * 2) Take only the last version of each file (Temp subquery) => accurate list is ok * 3) Join the result to file table to get fileindex, jobid and lstat information * - * TODO: On postgresql, this is done with -SELECT DISTINCT ON (PathId, FilenameId) FileIndex, Path, Name, LStat - FROM File JOIN Filename USING (FilenameId) JOIN Path USING (PathId) WHERE JobId IN (40341) - ORDER BY PathId, FilenameId, JobId DESC + * TODO: See if we can do the SORT only if needed (as an argument) */ bool db_get_file_list(JCR *jcr, B_DB *mdb, char *jobids, DB_RESULT_HANDLER *result_handler, void *ctx) @@ -1051,7 +1048,8 @@ bool db_get_file_list(JCR *jcr, B_DB *mdb, char *jobids, "JOIN Filename ON (Filename.FilenameId = Temp.FilenameId) " "JOIN Path ON (Path.PathId = Temp.PathId) " "JOIN File ON (File.FileId = Temp.FileId) " - "WHERE File.FileIndex > 0 ", +"WHERE File.FileIndex > 0 ORDER BY JobId, FileIndex ASC", /* Return sorted by JobId, */ + /* FileIndex for restore code */ jobids); #else /* diff --git a/bacula/src/dird/bsr.c b/bacula/src/dird/bsr.c index 4e03daa5a2..8820d6f31b 100644 --- a/bacula/src/dird/bsr.c +++ b/bacula/src/dird/bsr.c @@ -491,6 +491,7 @@ void print_bsr(UAContext *ua, RBSR *bsr) * Add a FileIndex to the list of BootStrap records. * Here we are only dealing with JobId's and the FileIndexes * associated with those JobIds. + * We expect that JobId, FileIndex are sorted ascending. */ void add_findex(RBSR *bsr, uint32_t JobId, int32_t findex) { diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 6e74306c99..d45acbf868 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -30,6 +30,8 @@ vtape driver General: +08Jul08 +ebl Add a sort to db_get_file_list() to improve bsr construction time. 07Jul08 kes Add a mtx-changer.conf file that is not overwritten during an upgrade. It fully configures the mtx-changer script.