Postgres perf, path migration, and shutdown race fixes
- Major query performance boost: replaced correlated subqueries with DistinctBy() in BaseItemRepository, added episode deduplication index, and increased default command timeout to 120s. - Fixed LibraryMonitor shutdown race: added disposal checks and exception handling in FileRefresher to prevent ObjectDisposedException. - Added PowerShell and SQL utilities for fixing Linux paths in config files and database; new scripts for WebDir and path migration. - Auto-fix for WebDir in startup.json on load; new helper scripts and docs. - Added automated weekly DB performance monitoring scripts and reporting. - Expanded documentation and README for all fixes, scripts, and migration steps. - Updated SQL scripts for index creation and diagnostics; improved output handling. - Updated db-config defaults and added new diagnostic/report files.
This commit is contained in:
+9
@@ -61,6 +61,14 @@ namespace Jellyfin.Database.Providers.Postgres.Migrations
|
||||
END IF;
|
||||
END $$;
|
||||
");
|
||||
|
||||
// 6. Index for episode deduplication by PresentationUniqueKey
|
||||
// Use case: Group and deduplicate episodes (used in GetItems queries)
|
||||
migrationBuilder.Sql(@"
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_baseitems_presentationuniquekey_episodes
|
||||
ON library.""BaseItems"" (""PresentationUniqueKey"", ""TopParentId"", ""IsVirtualItem"")
|
||||
WHERE ""Type"" = 'MediaBrowser.Controller.Entities.TV.Episode' AND ""PresentationUniqueKey"" IS NOT NULL;
|
||||
");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -72,6 +80,7 @@ namespace Jellyfin.Database.Providers.Postgres.Migrations
|
||||
migrationBuilder.Sql(@"DROP INDEX CONCURRENTLY IF EXISTS library.idx_baseitems_datecreated_filtered;");
|
||||
migrationBuilder.Sql(@"DROP INDEX CONCURRENTLY IF EXISTS library.idx_itemvaluesmap_itemvalueid_itemid;");
|
||||
migrationBuilder.Sql(@"DROP INDEX CONCURRENTLY IF EXISTS activitylog.idx_activitylogs_userid_datecreated;");
|
||||
migrationBuilder.Sql(@"DROP INDEX CONCURRENTLY IF EXISTS library.idx_baseitems_presentationuniquekey_episodes;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ public sealed class PostgresDatabaseProvider : IJellyfinDatabaseProvider
|
||||
Username = GetOption(customOptions, "username", e => e, () => "jellyfin")!,
|
||||
Password = GetOption(customOptions, "password", e => e, () => string.Empty)!,
|
||||
Pooling = GetOption(customOptions, "pooling", e => e.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase), () => true),
|
||||
CommandTimeout = GetOption(customOptions, "command-timeout", int.Parse, () => 30),
|
||||
CommandTimeout = GetOption(customOptions, "command-timeout", int.Parse, () => 120),
|
||||
Timeout = GetOption(customOptions, "connection-timeout", int.Parse, () => 15),
|
||||
Multiplexing = GetOption(customOptions, "multiplexing", e => e.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase), () => false),
|
||||
MaxPoolSize = GetOption(customOptions, "max-pool-size", int.Parse, () => 100),
|
||||
|
||||
Reference in New Issue
Block a user