I created a new ‘album’ table, using the same schema as ‘songs’. I then did ‘insert into album select * from songs where track = 1’. I now had a table with just one entry per album.
Next I took a hex editor to the mt-daapd binary. I searched for the string ‘distinct album from songs’ and replaced it with ‘select distinct album from album’. There were two occurrences to change.
If there is only one entry per album, couldn’t you remove the “distinct” from your “select distinct album from album” and get even faster results?
Another way you might solve your problem is to open songs.db in sqlite and create an index on album. The syntax would be:
create index idx_album on songs(album); and then undo your hack to permit the select distinct album from songs to run much faster against an index. It probably wouldn’t be quite as fast, but it would always be in sync.