aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
authorShadowghost <Shadowghost@users.noreply.github.com>2026-11-20 07:25:05 -0500
committerCody Robibero <cody@robibe.ro>2026-11-20 07:25:05 -0500
commitddb9fb275e946b53dd9faac9d65002b47833821b (patch)
tree44365478319193c68f9d23c30563d7b90d5a85a1 /Emby.Server.Implementations
parenta2ca4a7b84e89957547a9fb04a190b139c86e72f (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 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs8
1 files changed, 6 insertions, 2 deletions
diff --git a/Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs b/Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs
index a5ea02df51..dd96f75893 100644
--- a/Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs
+++ b/Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs
@@ -136,7 +136,7 @@ public class SqlSearchProvider : IInternalSearchProvider
dbQuery = ApplyTypeFilter(dbQuery, query.IncludeItemTypes, query.ExcludeItemTypes);
dbQuery = ApplyMediaTypeFilter(dbQuery, query.MediaTypes);
- dbQuery = ApplyParentFilter(dbQuery, query.ParentId);
+ dbQuery = ApplyParentFilter(dbContext, dbQuery, query.ParentId);
dbQuery = ApplyUserAccessFilter(dbContext, dbQuery, query);
dbQuery = ExcludeVersionsOfMatchedPrimaries(dbQuery);
@@ -205,6 +205,7 @@ public class SqlSearchProvider : IInternalSearchProvider
}
private static IQueryable<BaseItemEntity> ApplyParentFilter(
+ JellyfinDbContext context,
IQueryable<BaseItemEntity> query,
Guid? parentId)
{
@@ -214,7 +215,10 @@ public class SqlSearchProvider : IInternalSearchProvider
}
var pid = parentId.Value;
- return query.Where(e => e.ParentId == pid || e.Parents!.Any(p => p.ParentItemId == pid));
+ var descendantIds = context.AncestorIds
+ .Where(a => a.ParentItemId == pid)
+ .Select(a => a.ItemId);
+ return query.Where(e => e.ParentId == pid || descendantIds.Contains(e.Id));
}
private static IQueryable<BaseItemEntity> ExcludeVersionsOfMatchedPrimaries(IQueryable<BaseItemEntity> query)