From d6da6906a4b3426f05c5bf4ffe8bab4b2bc78ce8 Mon Sep 17 00:00:00 2001 From: brandon Date: Fri, 7 Aug 2026 11:59:17 -0400 Subject: Batch people lookups when building item DTOs GetBaseItemDtos already batch fetches user data, child counts, played counts and artists before its per item loop, but AttachPeople still ran one GetPeople query per item. Rendering a page of items (for example a large playlist) fired one extra query per row. Add GetPeopleByItems to IPeopleRepository, which reads every requested item in a single query over the people mapping table and returns full PersonInfo (role, type and sort order) grouped by item id. GetBaseItemDtos prefetches this once when the People field is requested and passes it into AttachPeople, which reads from the batch instead of querying per item. The single item GetBaseItemDto path keeps its existing per item behaviour when no batch is supplied. Adds a DtoService test asserting people resolve from the batch and the per item GetPeople is never called. --- MediaBrowser.Controller/Library/ILibraryManager.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'MediaBrowser.Controller/Library/ILibraryManager.cs') diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 6d85a1e401..5eae6e103f 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -605,6 +605,13 @@ namespace MediaBrowser.Controller.Library /// A dictionary mapping each item ID to its distinct people names. Items with no matching people are omitted. IReadOnlyDictionary> GetPeopleNamesByItems(IReadOnlyList itemIds, IReadOnlyList personTypes); + /// + /// Gets the people for multiple items in a single query, keyed by item id. + /// + /// The item IDs. + /// A dictionary mapping each item ID to its people. Items with no people are omitted. + IReadOnlyDictionary> GetPeopleByItems(IReadOnlyList itemIds); + /// /// Queries the items. /// -- cgit v1.2.3