From 2fe653fd1e7b7b87a0f8212ad1d2dfe40310f6e6 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 15 Jan 2023 00:59:46 -0600 Subject: [PATCH] Fixed: Speed up CleanupOrphanedTrackFiles housekeeper Tracks table is massive, so lets avoid re-writing 0s to items that are already 0 --- .../Housekeeping/Housekeepers/CleanupOrphanedTrackFiles.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedTrackFiles.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedTrackFiles.cs index e4d9f3845..f540384e4 100644 --- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedTrackFiles.cs +++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupOrphanedTrackFiles.cs @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers // Unlink where track no longer exists mapper.Execute(@"UPDATE ""TrackFiles"" SET ""AlbumId"" = 0 - WHERE ""Id"" IN ( + WHERE ""AlbumId"" <> 0 AND ""Id"" IN ( SELECT ""TrackFiles"".""Id"" FROM ""TrackFiles"" LEFT OUTER JOIN ""Tracks"" ON ""TrackFiles"".""Id"" = ""Tracks"".""TrackFileId"" @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers // Unlink Tracks where the Trackfiles entry no longer exists mapper.Execute(@"UPDATE ""Tracks"" SET ""TrackFileId"" = 0 - WHERE ""Id"" IN ( + WHERE ""TrackFileId"" <> 0 AND ""Id"" IN ( SELECT ""Tracks"".""Id"" FROM ""Tracks"" LEFT OUTER JOIN ""TrackFiles"" ON ""Tracks"".""TrackFileId"" = ""TrackFiles"".""Id""