mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05:46 +00:00
fix(library): use partial indexes for §6.9 remap lookup (#1105)
* fix(library): use partial indexes for §6.9 remap lookup The delta-sync remap detection ran a single lookup with an OR across content_hash and server_path. SQLite could not use the partial idx_track_remap_hash / idx_track_remap_path indexes for it: a partial index is only applied when the query's WHERE provably implies the index predicate (… != ''), and an OR spanning two columns blocks the per-branch index plan. The query degraded to a full track scan on every incoming row → O(rows × catalog), causing multi-minute stalls on large libraries (observed upsert_batch_remap exec_ms=162001 on a ~200k-track Navidrome sync, which in turn blocked all other writers on the single write mutex). Split it into two single-column lookups that each repeat the index predicate so the planner picks the matching partial index (SEARCH, not SCAN); hash is checked first, matching §6.9 strong-key priority. Adds an EXPLAIN QUERY PLAN regression test asserting index usage. * docs(changelog): note remap-lookup sync stall fix (PR #1105)
This commit is contained in:
@@ -36,6 +36,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
* On macOS, closing the window with the red close button always quit the app, even with "Minimize to Tray" enabled. The close button now respects the setting — with it on, the window hides to the tray instead of quitting, the same as the tray icon's "Hide".
|
||||
|
||||
### Library sync stalling for many seconds on large Navidrome collections
|
||||
|
||||
**By [@cucadmuh](https://github.com/cucadmuh), PR [#1105](https://github.com/Psychotoxical/psysonic/pull/1105)**
|
||||
|
||||
* On large libraries (reported with ~200,000 tracks on Navidrome), background library sync could lock up database writes for minutes at a time — playback history, ratings and other saves piled up waiting behind it.
|
||||
* Root cause: the track id-remap step ran a database lookup that couldn't use its indexes and scanned the entire track table once per incoming track, so the cost grew with the square of the library size. The lookup now uses the proper indexes, bringing it back to a fast, near-instant operation.
|
||||
|
||||
|
||||
|
||||
## [1.48.0]
|
||||
|
||||
Reference in New Issue
Block a user