From ff7ed3757df63803b70156ba0539126ed56d7ab2 Mon Sep 17 00:00:00 2001 From: Cedric CAFFY <cedric.caffy@cern.ch> Date: Fri, 13 Mar 2020 17:55:50 +0100 Subject: [PATCH] Updated statistics updater query, WIP --- statistics/TapeStatisticsUpdater.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/statistics/TapeStatisticsUpdater.cpp b/statistics/TapeStatisticsUpdater.cpp index 8243c1f066..25824a856b 100644 --- a/statistics/TapeStatisticsUpdater.cpp +++ b/statistics/TapeStatisticsUpdater.cpp @@ -45,10 +45,10 @@ void TapeStatisticsUpdater::updateTapeStatistics() { "'0' AS DIRTY," "COALESCE(NON_EMPTY_TAPE_STATS.NB_MASTER_FILES, 0) AS COMPUTED_NB_MASTER_FILES," "COALESCE(NON_EMPTY_TAPE_STATS.MASTER_DATA_IN_BYTES, 0) AS COMPUTED_MASTER_DATA_IN_BYTES," - "CASE WHEN COPY_NB = 1 THEN COALESCE(NON_EMPTY_TAPE_STATS.NB_MASTER_FILES, 0) ELSE 0 END AS NB_COPY_NB_1," - "CASE WHEN COPY_NB = 1 THEN COALESCE(NON_EMPTY_TAPE_STATS.MASTER_DATA_IN_BYTES, 0) ELSE 0 END AS COPY_NB_1_IN_BYTES," - "CASE WHEN COPY_NB > 1 THEN COALESCE(NON_EMPTY_TAPE_STATS.NB_MASTER_FILES, 0) ELSE 0 END AS NB_COPY_NB_GT_1," - "CASE WHEN COPY_NB > 1 THEN COALESCE(NON_EMPTY_TAPE_STATS.MASTER_DATA_IN_BYTES, 0) ELSE 0 END AS COPY_NB_GT_1_IN_BYTES " + "COALESCE(NON_EMPTY_TAPE_STATS.NB_COPY_NB_1,0) AS NB_COPY_NB_1," + "COALESCE(NON_EMPTY_TAPE_STATS.COPY_NB_1_IN_BYTES,0) AS COPY_NB_1_IN_BYTES," + "COALESCE(NON_EMPTY_TAPE_STATS.NB_COPY_NB_GT_1,0) AS NB_COPY_NB_GT_1," + "COALESCE(NON_EMPTY_TAPE_STATS.COPY_NB_GT_1_IN_BYTES,0) AS COPY_NB_GT_1_IN_BYTES " "FROM " "TAPE T " "LEFT OUTER JOIN " @@ -58,19 +58,18 @@ void TapeStatisticsUpdater::updateTapeStatistics() { "'0' AS DIRTY," "COUNT(TAPE_FILE.FSEQ) AS NB_MASTER_FILES," "SUM(ARCHIVE_FILE.SIZE_IN_BYTES) AS MASTER_DATA_IN_BYTES," - "ARCHIVE_ROUTE.COPY_NB " + "CASE WHEN TAPE_FILE.COPY_NB = 1 THEN COUNT(TAPE_FILE.FSEQ) ELSE 0 END AS NB_COPY_NB_1," + "CASE WHEN TAPE_FILE.COPY_NB = 1 THEN SUM(ARCHIVE_FILE.SIZE_IN_BYTES) ELSE 0 END AS COPY_NB_1_IN_BYTES," + "CASE WHEN TAPE_FILE.COPY_NB > 1 THEN COUNT(TAPE_FILE.FSEQ) ELSE 0 END AS NB_COPY_NB_GT_1," + "CASE WHEN TAPE_FILE.COPY_NB > 1 THEN SUM(ARCHIVE_FILE.SIZE_IN_BYTES) ELSE 0 END AS COPY_NB_GT_1_IN_BYTES " "FROM " "TAPE_FILE " "INNER JOIN ARCHIVE_FILE ON " "TAPE_FILE.ARCHIVE_FILE_ID = ARCHIVE_FILE.ARCHIVE_FILE_ID " - "INNER JOIN STORAGE_CLASS ON " - "ARCHIVE_FILE.STORAGE_CLASS_ID = STORAGE_CLASS.STORAGE_CLASS_ID " - "INNER JOIN ARCHIVE_ROUTE ON " - "STORAGE_CLASS.STORAGE_CLASS_ID = ARCHIVE_ROUTE.STORAGE_CLASS_ID " "WHERE " "TAPE_FILE.SUPERSEDED_BY_VID IS NULL AND " "TAPE_FILE.SUPERSEDED_BY_FSEQ IS NULL " - "GROUP BY TAPE_FILE.VID, ARCHIVE_ROUTE.COPY_NB" + "GROUP BY TAPE_FILE.VID, TAPE_FILE.COPY_NB" ") NON_EMPTY_TAPE_STATS ON " "T.VID = NON_EMPTY_TAPE_STATS.VID " "WHERE T.VID = TAPE_TO_UPDATE.VID" -- GitLab