From 81a823a5d021edf1266599ad86e61d0af713f40b Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sun, 18 Oct 2015 11:39:00 +0200 Subject: [PATCH] Enhance bvfs performance .bvfs_update for MySQL Bug reported here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=737821 --- bacula/src/cats/bvfs.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bacula/src/cats/bvfs.c b/bacula/src/cats/bvfs.c index d73a49bbcd..349407380c 100644 --- a/bacula/src/cats/bvfs.c +++ b/bacula/src/cats/bvfs.c @@ -481,7 +481,19 @@ static int update_path_hierarchy_cache(JCR *jcr, "AND h.PPathId NOT IN (SELECT PathId FROM PathVisibility WHERE JobId=%s)", jobid, jobid, jobid ); - } else { + } else if (mdb->bdb_get_type_index() == SQL_TYPE_MYSQL) { + Mmsg(mdb->cmd, + "INSERT INTO PathVisibility (PathId, JobId) " + "SELECT a.PathId,%s " + "FROM ( " + "SELECT DISTINCT h.PPathId AS PathId " + "FROM PathHierarchy AS h " + "JOIN PathVisibility AS p ON (h.PathId=p.PathId) " + "WHERE p.JobId=%s) AS a " + "LEFT JOIN PathVisibility AS b ON (b.JobId=%s and a.PathId = b.PathId) " + "WHERE b.PathId IS NULL", jobid, jobid, jobid); + + } else { /* TODO: Test the MYSQL Query with PostgreSQL */ Mmsg(mdb->cmd, "INSERT INTO PathVisibility (PathId, JobId) " "SELECT a.PathId,%s " -- 2.39.5