]> git.sur5r.net Git - bacula/bacula/commitdiff
Improve speed of BVFS with SQLite, Thanks to J.Starek
authorEric Bollengier <eric@eb.homelinux.org>
Mon, 31 Oct 2011 09:54:55 +0000 (10:54 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 31 Oct 2011 10:01:36 +0000 (11:01 +0100)
bacula/src/cats/bvfs.c

index 56d94c3663f5022e19ee729ce5550acea78350b3..0e75beb8c0fbcfef7c844898f493a07e786bfd59 100644 (file)
@@ -378,7 +378,17 @@ static void update_path_hierarchy_cache(JCR *jcr,
       free(result);
    }
 
-   Mmsg(mdb->cmd, 
+   if (mdb->db_get_type_index() == SQL_TYPE_SQLITE3) {
+      Mmsg(mdb->cmd, 
+ "INSERT INTO PathVisibility (PathId, JobId) "
+   "SELECT DISTINCT h.PPathId AS PathId, %s "
+     "FROM PathHierarchy AS h "
+    "WHERE h.PathId IN (SELECT PathId FROM PathVisibility WHERE JobId=%s) "
+      "AND h.PPathId NOT IN (SELECT PathId FROM PathVisibility WHERE JobId=%s)",
+           jobid, jobid, jobid );
+
+   } else {
+      Mmsg(mdb->cmd, 
   "INSERT INTO PathVisibility (PathId, JobId)  "
    "SELECT a.PathId,%s "
    "FROM ( "
@@ -390,6 +400,7 @@ static void update_path_hierarchy_cache(JCR *jcr,
           "FROM PathVisibility "
          "WHERE JobId=%s) AS b ON (a.PathId = b.PathId) "
    "WHERE b.PathId IS NULL",  jobid, jobid, jobid);
+   }
 
    do {
       QUERY_DB(jcr, mdb, mdb->cmd);