aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/Program.cs
diff options
context:
space:
mode:
authorClaus Vium <cvium@users.noreply.github.com>2021-05-24 13:50:34 +0200
committerGitHub <noreply@github.com>2021-05-24 13:50:34 +0200
commitde80ce93db472b52df4b7dfbcd348480d780a4c2 (patch)
tree3647bb422d51e95434184ee29b209c7f1ee6e591 /Jellyfin.Server/Program.cs
parent74ba079c5c2dce34e5c800e085b7674c40448b62 (diff)
parent6db229af5deb6a00035ddcfebc4fd9db3b6a5336 (diff)
Merge pull request #6031 from ferferga/sql-optimization
Run SQLite query planner optimization at shutdown/restart
Diffstat (limited to 'Jellyfin.Server/Program.cs')
-rw-r--r--Jellyfin.Server/Program.cs10
1 files changed, 10 insertions, 0 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index c10b2ddb3..3a3d7415b 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -12,10 +12,12 @@ using System.Threading.Tasks;
using CommandLine;
using Emby.Server.Implementations;
using Emby.Server.Implementations.IO;
+using Jellyfin.Server.Implementations;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Extensions;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -220,6 +222,14 @@ namespace Jellyfin.Server
}
finally
{
+ _logger.LogInformation("Running query planner optimizations in the database... This might take a while");
+ // Run before disposing the application
+ using var context = new JellyfinDbProvider(appHost.ServiceProvider, appPaths).CreateContext();
+ if (context.Database.IsSqlite())
+ {
+ context.Database.ExecuteSqlRaw("PRAGMA optimize");
+ }
+
appHost.Dispose();
}