diff options
| author | Cody Robibero <cody@robibe.ro> | 2026-07-26 16:18:49 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-26 16:18:49 -0400 |
| commit | 1e4d126cb9f1590cfdc0e731647b93836d1a8867 (patch) | |
| tree | baf2e7ba19fc2026508d7e67567cc4f2f66c9336 /src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration | |
| parent | b04614e18d2aeed8d3d3de920c381c6bd5b97bdb (diff) | |
| parent | f3a1d56c563c71573ed2e7681b347533897ee70c (diff) | |
Merge pull request #17422 from Shadowghost/performance
Reduce correlated subqueries to improve query performance
Diffstat (limited to 'src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration')
| -rw-r--r-- | src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/BaseItemConfiguration.cs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/BaseItemConfiguration.cs b/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/BaseItemConfiguration.cs index 8556fb7bb3..ee36be035b 100644 --- a/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/BaseItemConfiguration.cs +++ b/src/Jellyfin.Database/Jellyfin.Database.Implementations/ModelConfiguration/BaseItemConfiguration.cs @@ -61,6 +61,11 @@ public class BaseItemConfiguration : IEntityTypeConfiguration<BaseItemEntity> builder.HasIndex(e => new { e.TopParentId, e.MediaType, e.IsVirtualItem, e.DateCreated }); // resume builder.HasIndex(e => new { e.MediaType, e.TopParentId, e.IsVirtualItem, e.PresentationUniqueKey }); + // alternate versions of an item, e.g. resolving the played date of a version onto its primary. + // Filtered: almost no item has a primary version, and an index covering those rows too would tempt + // the planner into serving "PrimaryVersionId IS NULL" - true for the whole library - out of it. + builder.HasIndex(e => e.PrimaryVersionId) + .HasFilter("\"PrimaryVersionId\" IS NOT NULL"); // sorted library queries (e.g., Series sorted by SortName) builder.HasIndex(e => new { e.Type, e.TopParentId, e.SortName }); // NextUp: per-series episode ordering (index seek + range scan on season/episode) |
