Skip to content

Speed up UpdateOrInsertItems for related information - #17554

Merged
crobibero merged 2 commits into
jellyfin:masterfrom
IDisposable:fix/faster-update-items
Aug 8, 2026
Merged

crobibero merged 2 commits into
jellyfin:masterfrom
IDisposable:fix/faster-update-items

Conversation

@IDisposable

Copy link
Copy Markdown
Contributor

The processing to find matching existing items and existing item values uses linear searches which are O(n²).

Changes
Replace the existing items ToArray() + First() scan with ToHashSet() + Contains() key lookup.
Replace the existing values .ToArray() + First() scan with ToDictionary() and dictionary lookup by key.

Code assistance
None

Issues
Speed up bulk saves of items.

Makes the test O(log n)
Replace the O(n²)  array .First scan with a dictionary lookup
@IDisposable IDisposable added the backend Related to the server backend label Aug 6, 2026
@jellyfin-bot

Copy link
Copy Markdown
Contributor

Jellyfin API (v 12.0.0)


Result


No differences. Specifications are equivalent

@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@IDisposable IDisposable added the area:database Issues relating to the server databases and/or database access label Aug 6, 2026
@Shadowghost Shadowghost moved this from Todo to Review in Jellyfin v12 Aug 6, 2026
@Shadowghost
Shadowghost requested a review from a team August 6, 2026 06:33
@crobibero crobibero moved this from Review to Approved in Jellyfin v12 Aug 6, 2026
@crobibero
crobibero merged commit 830d93e into jellyfin:master Aug 8, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in Jellyfin v12 Aug 8, 2026
@IDisposable
IDisposable deleted the fix/faster-update-items branch August 9, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:database Issues relating to the server databases and/or database access backend Related to the server backend

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants