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:
@@ -0,0 +1,23 @@
|
||||
-- PostgreSQL Performance Fix for Episode Queries
|
||||
-- Run this script to add the missing index for PresentationUniqueKey
|
||||
-- This will significantly speed up episode deduplication queries
|
||||
\pset pager off
|
||||
|
||||
-- Create the index (CONCURRENTLY means it won't lock the table during creation)
|
||||
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;
|
||||
|
||||
-- Verify the index was created
|
||||
SELECT
|
||||
schemaname,
|
||||
tablename,
|
||||
indexname,
|
||||
indexdef
|
||||
FROM pg_indexes
|
||||
WHERE schemaname = 'library'
|
||||
AND indexname = 'idx_baseitems_presentationuniquekey_episodes';
|
||||
|
||||
-- Check index size
|
||||
SELECT
|
||||
pg_size_pretty(pg_relation_size('library.idx_baseitems_presentationuniquekey_episodes'::regclass)) AS index_size;
|
||||
Reference in New Issue
Block a user