From 07d31c6ba51bdbacb0be4ff5631e4567d7ea6980 Mon Sep 17 00:00:00 2001 From: theguymadmax Date: Wed, 8 Oct 2025 11:23:20 -0400 Subject: Improve performance on people query (#14963) --- Jellyfin.Server.Implementations/Item/BaseItemRepository.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Jellyfin.Server.Implementations') diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs index 0884efa43..ef444b930 100644 --- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs +++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs @@ -1875,10 +1875,17 @@ public sealed class BaseItemRepository if (filter.PersonIds.Length > 0) { + var peopleEntityIds = context.BaseItems + .WhereOneOrMany(filter.PersonIds, b => b.Id) + .Join( + context.Peoples, + b => b.Name, + p => p.Name, + (b, p) => p.Id); + baseQuery = baseQuery - .Where(e => - context.PeopleBaseItemMap.Where(w => context.BaseItems.Where(r => filter.PersonIds.Contains(r.Id)).Any(f => f.Name == w.People.Name)) - .Any(f => f.ItemId == e.Id)); + .Where(e => context.PeopleBaseItemMap + .Any(m => m.ItemId == e.Id && peopleEntityIds.Contains(m.PeopleId))); } if (!string.IsNullOrWhiteSpace(filter.Person)) -- cgit v1.2.3