Run SQLite query planner optimization at shutdown/restart
This commit is contained in:
parent
74ba079c5c
commit
69baa9c467
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user