mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-16 05:43:54 +03:00
[PR #6031] [MERGED] Run SQLite query planner optimization at shutdown/restart #10786
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/jellyfin/jellyfin/pull/6031
Author: @ferferga
Created: 5/12/2021
Status: ✅ Merged
Merged: 5/24/2021
Merged by: @cvium
Base:
master← Head:sql-optimization📝 Commits (3)
69baa9cRun SQLite query planner optimization at shutdown/restart3b82211Create scheduled task for database optimization6db229aAddress review comments📊 Changes
5 files changed (+118 additions, -2 deletions)
View changed files
📝
Emby.Server.Implementations/Emby.Server.Implementations.csproj(+1 -0)📝
Emby.Server.Implementations/Localization/Core/en-US.json(+3 -1)📝
Emby.Server.Implementations/Localization/Core/es.json(+3 -1)➕
Emby.Server.Implementations/ScheduledTasks/Tasks/OptimizeDatabaseTask.cs(+101 -0)📝
Jellyfin.Server/Program.cs(+10 -0)📄 Description
Runs
PRAGMA optimizeafter disposing Jellyfin's application host. According to SQLite docs, this should be run at the end of the connection, when it's most suitable to run the query planner optimizations.Source https://www.sqlite.org/pragma.html#pragma_optimize and https://sqlite.org/lang_analyze.html
EFCore arbitrarily creates or reuses connections for database contexts (based in EF6, not EFCore documentation I could find, https://docs.microsoft.com/en-us/ef/ef6/fundamentals/connection-management) but I assume that with SQLite provider (given all the concurrency issues it has) the same connection is reused no matter what, so we're taking full advantage of the query planner. More insights on this are appreciated.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.