Fixed: Speed up CleanupOrphanedTrackFiles housekeeper

Tracks table is massive, so lets avoid re-writing 0s to items that are already 0
pull/3295/head
Qstick 2 years ago
parent 3c9a0ebbf1
commit 2fe653fd1e

@ -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""

Loading…
Cancel
Save