mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
bca0acbaff
* 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)