[Fix][Backport]Music cleanup hanging on large MySQL databases #11801
Music library cleanup, both on library update, and the overall facility avilable from settings menu, is hanging on very large MySQL (or MariaDB) databases. Smaller db can benefit for a more efficient process too.
The issue is
It is unsurprizing that doing a "NOT IN" on an non-indexed table with 370k rows is unsuccessful!
In comparison testing has proven that an additional step of creating a temp table of unique artist ids to keep with an index (primary key), and using that in the "NOT IN" works reasonably with both few and many records on both MySQL and SQLite.
Look at having a lot of artists, then removing a small number of them by changes to music files.
@MilhouseVH any change of testing this on your MySQL system?
Tested on my RPi2 with MySQL 5.5 and it's working OK (confirmed the new query is being executed by enabling the MySQL query log). Unfortunately my music library isn't particularly large (8,000 songs or so) and is not in need of cleaning so from a performance point of view I can't really give an indication of the benefit but it looks sane.
I'll include it in tonight's build. Thanks Dave.
Thanks @MilhouseVH that will be really useful, I have a test user with RPi and 150k of songs, 30k artists. The SQL works manually, but good to try it in Kodi. His big MySQL db has been turning up some issues for me to fix.