diff options
| author | Shadowghost <Shadowghost@users.noreply.github.com> | 2026-11-20 07:25:05 -0500 |
|---|---|---|
| committer | Cody Robibero <cody@robibe.ro> | 2026-11-20 07:25:05 -0500 |
| commit | ddb9fb275e946b53dd9faac9d65002b47833821b (patch) | |
| tree | 44365478319193c68f9d23c30563d7b90d5a85a1 /Jellyfin.Server.Implementations/Item/BaseItemRepository.TranslateQuery.cs | |
| parent | a2ca4a7b84e89957547a9fb04a190b139c86e72f (diff) | |
Backport pull request #18258 from jellyfin/release-12.z
Look up descendants by parent instead of a correlated EXISTS
Original-merge: e60484a1cef1ceca4aea7135396178139dc93132
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Cody Robibero <cody@robibe.ro>
Diffstat (limited to 'Jellyfin.Server.Implementations/Item/BaseItemRepository.TranslateQuery.cs')
| -rw-r--r-- | Jellyfin.Server.Implementations/Item/BaseItemRepository.TranslateQuery.cs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.TranslateQuery.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.TranslateQuery.cs index e24e71bb5a..76889cb095 100644 --- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.TranslateQuery.cs +++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.TranslateQuery.cs @@ -1098,8 +1098,10 @@ public sealed partial class BaseItemRepository if (filter.AncestorIds.Length > 0) { - var ancestorFilter = filter.AncestorIds.OneOrManyExpressionBuilder<AncestorId, Guid>(f => f.ParentItemId); - baseQuery = baseQuery.Where(e => e.Parents!.AsQueryable().Any(ancestorFilter)); + var descendantIds = context.AncestorIds + .WhereOneOrMany(filter.AncestorIds, a => a.ParentItemId) + .Select(a => a.ItemId); + baseQuery = baseQuery.Where(e => descendantIds.Contains(e.Id)); } if (filter.DescendantOfId.HasValue) @@ -1119,8 +1121,14 @@ public sealed partial class BaseItemRepository if (!string.IsNullOrWhiteSpace(filter.AncestorWithPresentationUniqueKey)) { - baseQuery = baseQuery - .Where(e => context.BaseItems.Where(e => e.Id != EF.Constant(PlaceholderId)).Where(f => f.PresentationUniqueKey == filter.AncestorWithPresentationUniqueKey).Any(f => f.Children!.Any(w => w.ItemId == e.Id))); + var ancestorKey = filter.AncestorWithPresentationUniqueKey; + var keyedAncestorIds = context.BaseItems + .Where(f => f.Id != EF.Constant(PlaceholderId) && f.PresentationUniqueKey == ancestorKey) + .Select(f => f.Id); + var descendantIds = context.AncestorIds + .Where(a => keyedAncestorIds.Contains(a.ParentItemId)) + .Select(a => a.ItemId); + baseQuery = baseQuery.Where(e => descendantIds.Contains(e.Id)); } if (!string.IsNullOrWhiteSpace(filter.SeriesPresentationUniqueKey)) |
