Remove repeated membership queries and full-library scans from local workflows #48
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
managed_track_rows first fetches track IDs and then runs two additional queries for each track. The per-track membership query is not supported by an index beginning with apple_library_track_id.
Interactive match scans the entire beets library for every managed Apple track, including tracks that will immediately be skipped because they are already resolved. Explicit replacement/displacement handling performs additional scans.
Proposed change
Fetch managed tracks and memberships with a joined/batched query and group the rows. Build a live association index once for interactive matching and update it after decisions. Add an index only if the resulting query plan needs it; any schema change must use a numbered forward-only migration.
Acceptance criteria
References:
beetsplug/appleplaylists/state.py:178-211,__init__.py:412-435,__init__.py:479-485. Audit finding 7 (medium).