Files
SpotiFLAC-Mobile/lib/services/link/sync
zarzet 9ea69df77d perf(link): match unmapped history songs in batches
Applying a peer's listening totals looked up each song this device has
no key for with its own awaited query inside the statistics write
transaction (DATA-11). A first sync of a year of listening, about 3,000
songs, made about 3,000 sequential round trips while holding the write
lock the 10 s listening flush waits on.

The songs are now looked up 200 at a time with a VALUES list and the
same correlated query per song (NOCASE title and artist, newest day
first, first row), so each keeps the key it got before. The lookups
still run before the batch writes, against the same totals. Songs
without a title no longer query at all; they keep the author's key as
before.

Measured on the host (FFI, isolate, M-series Mac): 3,000 lookups took
237 to 2,016 ms one at a time and 8 to 111 ms in batches, with identical
results; the new test's apply reads 7 statements instead of 459. The
plan still searches idx_listening_title_artist per song.
2026-10-31 01:04:45 +07:00
..