aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-02-18 20:28:42 +0100
committerShadowghost <Ghost_of_Stone@web.de>2026-02-18 20:28:42 +0100
commit3a090a571682033f54cc2824d4003ff873467b4c (patch)
treed43a03e53060f71d2df48b7b9a80c01e2093b9a2 /MediaBrowser.Controller
parentf96c399e62575a78195b4eb6eace3ccd2393bdb3 (diff)
Optimize item count calculation for named items
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Library/ILibraryManager.cs10
-rw-r--r--MediaBrowser.Controller/Persistence/IItemRepository.cs11
2 files changed, 21 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs
index e73dede1d4..5cfb940891 100644
--- a/MediaBrowser.Controller/Library/ILibraryManager.cs
+++ b/MediaBrowser.Controller/Library/ILibraryManager.cs
@@ -707,6 +707,16 @@ namespace MediaBrowser.Controller.Library
ItemCounts GetItemCounts(InternalItemsQuery query);
/// <summary>
+ /// Gets item counts for a "by-name" item using an optimized query path.
+ /// </summary>
+ /// <param name="kind">The kind of the name item.</param>
+ /// <param name="id">The ID of the name item.</param>
+ /// <param name="relatedItemKinds">The item kinds to count.</param>
+ /// <param name="user">The user for access filtering.</param>
+ /// <returns>The item counts grouped by type.</returns>
+ ItemCounts GetItemCountsForNameItem(BaseItemKind kind, Guid id, BaseItemKind[] relatedItemKinds, User? user);
+
+ /// <summary>
/// Batch-fetches child counts for multiple parent folders.
/// Returns the count of immediate children (non-recursive) for each parent.
/// </summary>
diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs
index f1b27c52db..bcbbcc4785 100644
--- a/MediaBrowser.Controller/Persistence/IItemRepository.cs
+++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs
@@ -112,6 +112,17 @@ public interface IItemRepository
ItemCounts GetItemCounts(InternalItemsQuery filter);
+ /// <summary>
+ /// Gets item counts for a "by-name" item (Person, MusicArtist, Genre, MusicGenre, Studio, Year)
+ /// using an optimized query that starts from the mapping table instead of scanning all BaseItems.
+ /// </summary>
+ /// <param name="kind">The kind of the name item.</param>
+ /// <param name="id">The ID of the name item.</param>
+ /// <param name="relatedItemKinds">The item kinds to count.</param>
+ /// <param name="accessFilter">A pre-configured query with user access filtering settings.</param>
+ /// <returns>The item counts grouped by type.</returns>
+ ItemCounts GetItemCountsForNameItem(BaseItemKind kind, Guid id, BaseItemKind[] relatedItemKinds, InternalItemsQuery accessFilter);
+
QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery filter);
QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery filter);