From ff8eb0b67f6d9558eccf7fcbf2ac39d04b1e6848 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 11 Mar 2018 16:26:55 +0100 Subject: [PATCH] Added additional indexes to speed up DecisionMaker performance. --- ..._update_series_episodes_history_indexes.cs | 24 +++++++++++++++++++ src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 2 files changed, 25 insertions(+) create mode 100644 src/NzbDrone.Core/Datastore/Migration/120_update_series_episodes_history_indexes.cs diff --git a/src/NzbDrone.Core/Datastore/Migration/120_update_series_episodes_history_indexes.cs b/src/NzbDrone.Core/Datastore/Migration/120_update_series_episodes_history_indexes.cs new file mode 100644 index 000000000..e2363a836 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/120_update_series_episodes_history_indexes.cs @@ -0,0 +1,24 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(120)] + public class update_series_episodes_history_indexes : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Create.Index().OnTable("Series").OnColumn("TvdbId").Ascending(); + Create.Index().OnTable("Episodes").OnColumn("SeriesId").Ascending() + .OnColumn("AirDate").Ascending(); + + Delete.Index().OnTable("History").OnColumn("EpisodeId"); + Create.Index().OnTable("History").OnColumn("EpisodeId").Ascending() + .OnColumn("Date").Descending(); + + Delete.Index().OnTable("History").OnColumn("DownloadId"); + Create.Index().OnTable("History").OnColumn("DownloadId").Ascending() + .OnColumn("Date").Descending(); + } + } +} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index aa3eb8e8f..789aa01ca 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -224,6 +224,7 @@ +