diff options
| author | Fernando Fernández <ferferga@hotmail.com> | 2021-05-11 23:26:00 +0200 |
|---|---|---|
| committer | Fernando Fernández <ferferga@hotmail.com> | 2021-05-24 10:45:21 +0200 |
| commit | 69baa9c4679d376f001cc71ec0a0d9a1791e7adf (patch) | |
| tree | c65fa687e8da094a1835fe3a201e2d2a760ef4b7 /Jellyfin.Server/Program.cs | |
| parent | 74ba079c5c2dce34e5c800e085b7674c40448b62 (diff) | |
Run SQLite query planner optimization at shutdown/restart
Diffstat (limited to 'Jellyfin.Server/Program.cs')
| -rw-r--r-- | Jellyfin.Server/Program.cs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index c10b2ddb3..d0f10b467 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; @@ -221,6 +223,14 @@ namespace Jellyfin.Server finally { appHost.Dispose(); + _logger.LogInformation("Running query planner optimizations in the database... This might take a while"); + + // Run after disposing the application + using var context = new JellyfinDbProvider(appHost.ServiceProvider, appPaths).CreateContext(); + if (context.Database.IsSqlite()) + { + context.Database.ExecuteSqlRaw("PRAGMA optimize"); + } } if (_restartOnShutdown) |
