Issues when importing playlists

Issue description:

Hi.

When all the samba server is scanned, tags fetched and so on, it seems next step is importing playlist. My dataset is somehow big (1TB). I see app getting stuck on this state for too much time. In logs I see issues like that:

2025-06-20 10:56:14.151 Error/QueryBuilder: Query: SELECT songs._id, songs.updated_at, songs.provider_id, songs.external_id, songs.external_data, songs.album_id, songs.date_added, songs.disc, songs.display_artist, songs.duration, songs.fanart, songs.file, songs.genres, songs.last_played, songs.lyrics, songs.offline_status, songs.play_count, songs.rating, songs.sort_title, songs.thumbnail, songs.title, songs.track, songs.year, songs.user_rating, songs.is_favorite, songs.source_library, songs.remote_play, songs.resume_point, songs.comment, songs.mb_track_id, songs.bpm, songs.display_album_artist, songs.display_composer, songs.codec, songs.bitrate, songs.sample_rate, songs.bits_per_sample, songs.channel_count, songs.clip_start, songs.clip_end, songs.languages, songs.local_thumbnail, songs.fav_date, songs.explicit, songs.mood, songs.tags, songs.skipped, songs.last_skipped, songs.styles, songs.exclude_mix, songs.default_lyrics, CASE WHEN songs.thumbnail IS NULL THEN albums.thumbnail ELSE songs.thumbnail END, CASE WHEN (songs.local_thumbnail IS NULL AND songs.thumbnail IS NULL) THEN albums.local_thumbnail ELSE songs.local_thumbnail END, albums.title FROM songs LEFT JOIN albums ON (songs.album_id=albums._id) WHERE (songs.provider_id=?) AND (songs.file LIKE ?) (‘1’,‘%smb://192.168.148.132/music/Pop-Rock/Ñ Los Exitos del Año/Ñ Los Exitos del Año 2012/218-maki_feat._kilian_dominguez_and_j._orleans-yo_a_ti_te_quiero-vpe.mp3’) [1 in 281.86ms]

Not sure if that could be related but “Importing playlists” never ends…

Could you take a look?

Logs:

Upload description: zelazon-20250620-1 and zelazon-20250620-2

Additional information:

 

 

Reproduction steps:

 
Maybe not easy to reproduce. Just synchronising huge media server through samba with a lot of playlists? Tags are scanned in a reasonable time, but it seems to be something wrong with playlists
 

Media provider:

Samba

Screenshots:

     

Seems the database is slow on your device.

Try to go to Advanced settings / Cleanup internal states.

I tried. Status is still “Importing playlist”. Logs keep showing a lot of errors:

2025-06-20 13:19:33.813 Error/QueryBuilder: Query: SELECT songs.file FROM playlists_entries INNER JOIN songs ON (playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file) WHERE playlists_entries.playlist_id = 937 AND songs.resume_point>0 ORDER BY songs.last_played DESC LIMIT 1 (‘’) [0 in 103.94ms (RAW/false)]
2025-06-20 13:19:33.814 Verbose/QueryBuilder: Query: UPDATE playlists SET resume_file = ? WHERE playlists._id=937 (‘’) [0 in 0.50ms (RAW/true)]
2025-06-20 13:19:33.921 Error/QueryBuilder: Query: SELECT songs.file FROM playlists_entries INNER JOIN songs ON (playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file) WHERE playlists_entries.playlist_id = 938 AND songs.resume_point>0 ORDER BY songs.last_played DESC LIMIT 1 (‘’) [0 in 104.96ms (RAW/false)]
2025-06-20 13:19:33.923 Verbose/QueryBuilder: Query: UPDATE playlists SET resume_file = ? WHERE playlists._id=938 (‘’) [0 in 0.49ms (RAW/true)]
2025-06-20 13:19:34.025 Error/QueryBuilder: Query: SELECT songs.file FROM playlists_entries INNER JOIN songs ON (playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file) WHERE playlists_entries.playlist_id = 939 AND songs.resume_point>0 ORDER BY songs.last_played DESC LIMIT 1 (‘’) [0 in 100.57ms (RAW/false)]
2025-06-20 13:19:34.027 Verbose/QueryBuilder: Query: UPDATE playlists SET resume_file = ? WHERE playlists._id=939 (‘’) [0 in 0.55ms (RAW/true)]
2025-06-20 13:19:34.137 Error/QueryBuilder: Query: SELECT songs._id, songs.updated_at, songs.provider_id, songs.external_id, songs.external_data, songs.album_id, songs.date_added, songs.disc, songs.display_artist, songs.duration, songs.fanart, songs.file, songs.genres, songs.last_played, songs.lyrics, songs.offline_status, songs.play_count, songs.rating, songs.sort_title, songs.thumbnail, songs.title, songs.track, songs.year, songs.user_rating, songs.is_favorite, songs.source_library, songs.remote_play, songs.resume_point, songs.comment, songs.mb_track_id, songs.bpm, songs.display_album_artist, songs.display_composer, songs.codec, songs.bitrate, songs.sample_rate, songs.bits_per_sample, songs.channel_count, songs.clip_start, songs.clip_end, songs.languages, songs.local_thumbnail, songs.fav_date, songs.explicit, songs.mood, songs.tags, songs.skipped, songs.last_skipped, songs.styles, songs.exclude_mix, songs.default_lyrics, CASE WHEN songs.thumbnail IS NULL THEN albums.thumbnail ELSE songs.thumbnail END, CASE WHEN (songs.local_thumbnail IS NULL AND songs.thumbnail IS NULL) THEN albums.local_thumbnail ELSE songs.local_thumbnail END, albums.title FROM songs LEFT JOIN albums ON (songs.album_id=albums.id) WHERE (songs.provider_id=?) AND (songs.file LIKE ?) (‘1’,'%smb://192.168.148.132/music/Dance/Future Trance/Future Trance vol.41/203_michael_mind-ride_like_the_wind(single_version).mp3’) [1 in 413.35ms]
2025-06-20 13:19:34.139 Error/QueryBuilder: Query: SELECT songs.file FROM playlists_entries INNER JOIN songs ON (playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file) WHERE playlists_entries.playlist_id = 940 AND songs.resume_point>0 ORDER BY songs.last_played DESC LIMIT 1 (‘’) [0 in 109.83ms (RAW/false)]
2025-06-20 13:19:34.140 Verbose/QueryBuilder: Query: UPDATE playlists SET resume_file = ? WHERE playlists._id=940 (‘’) [0 in 0.52ms (RAW/true)]
2025-06-20 13:19:34.267 Error/QueryBuilder: Query: SELECT songs.file FROM playlists_entries INNER JOIN songs ON (playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file) WHERE playlists_entries.playlist_id = 941 AND songs.resume_point>0 ORDER BY songs.last_played DESC LIMIT 1 (‘’) [0 in 126.75ms (RAW/false)]
2025-06-20 13:19:34.269 Verbose/QueryBuilder: Query: UPDATE playlists SET resume_file = ? WHERE playlists._id=941 (‘’) [0 in 0.48ms (RAW/true)]
2025-06-20 13:19:34.383 Error/QueryBuilder: Query: SELECT songs.file FROM playlists_entries INNER JOIN songs ON (playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file) WHERE playlists_entries.playlist_id = 942 AND songs.resume_point>0 ORDER BY songs.last_played DESC LIMIT 1 (‘’) [0 in 109.73ms (RAW/false)]
2025-06-20 13:19:34.384 Verbose/QueryBuilder: Query: UPDATE playlists SET resume_file = ? WHERE playlists._id=942 (‘’) [0 in 0.38ms (RAW/true)]
2025-06-20 13:19:34.497 Error/QueryBuilder: Query: SELECT songs.file FROM playlists_entries INNER JOIN songs ON (playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file) WHERE playlists_entries.playlist_id = 943 AND songs.resume_point>0 ORDER BY songs.last_played DESC LIMIT 1 (‘’) [0 in 115.48ms (RAW/false)]
2025-06-20 13:19:34.498 Verbose/QueryBuilder: Query: UPDATE playlists SET resume_file = ? WHERE playlists._id=943 (‘’) [0 in 0.20ms (RAW/true)]

Don’t post large snippet like that …

And those are not real errors, just slow queries.

this is not an error?

2025-06-20 13:19:33.813 Error/QueryBuilder: Query: SELECT songs.file FROM playlists_entries INNER JOIN songs ON (playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file) WHERE playlists_entries.playlist_id = 937 AND songs.resume_point>0 ORDER BY songs.last_played DESC LIMIT 1 (‘’) [0 in 103.94ms (RAW/false)]

bear in mind “songs” table can be huge. Maybe you should move joining conditions to WHERE place (first filter and then join)

SELECT songs.file FROM playlists_entries INNER JOIN songs ON (playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file) WHERE playlists_entries.playlist_id = 943 AND songs.resume_point>0 ORDER BY songs.last_played DESC LIMIT 1

==>

SELECT songs.file FROM playlists_entries INNER JOIN songs WHERE playlists_entries.playlist_id = 943 AND songs.resume_point>0 AND playlists_entries.provider_id = songs.provider_id and playlists_entries.file = songs.file ORDER BY songs.last_played DESC LIMIT 1

No it’s not an error …, it’s logged as error as it’s slow and helps me find issues with the tools I have to parse logs.

And since I don’t have time to explain SQL here’s the chatGPT answer to your suggestion.

So what’s the practical difference?

Aspect Query ① Query ②
Validity Always valid Invalid on practically every modern DBMS
Readability / maintenance Clear separation of join logic vs row filters Harder to read; predicates all mixed together
Outer-join behaviour Safe: LEFT JOIN … ON … then put optional filters in WHERE Moving ON predicates to WHERE after a LEFT JOIN would turn it into an inner join, changing results
Performance (when valid) Identical to ② — optimiser derives the same plan Identical to ①

Bottom line:
Use the first form. It’s portable, readable, and the only safe choice when outer joins or more complex queries are involved. The second form is, at best, outdated SQL-89 style — and in this exact syntax, it simply fails to run.

I do not find respectful the way you talk to me honestly. I’m just trying to help to debug issues i find when using your app. I worked with SQL for years and also with ChatGPT and other AI agents. Two things:

  • SQL: you should always filter first and then join if you don’t wanna have performance issues, or rely in automatic optimisations from DBMS (not always work)
  • AI: ChatGPT is quite bad for technical matters

You have a great app. Your customer support should improve. I will not buy the app.

I do not find respectful, people who tries to explain that I’m wrong without thinking that they do not have the proper knowledge beforehand …

I used chatGPT to gain time and explain the actual result …

I perfectly know those SQLs queries and perfectly know why they are the way they are. I perfectly know how the android SQLite works and how it optimize too after 12 years of using it for millions users .

See the explain plans for both …

Exactly the same, one have a proper style that is consistent with all the million SQL code in the app, the other brings nothing to the table.

So I’m sorry that you are offended by quick answer to not loose too much time on 100% irrelevant stuff but do you really think customer support should lose time to explain SQL to users instead of doing actual useful stuff ?

I really wonder why I bother offering support when people act like that …

Should do like all the other apps, no forum, no support and have a quiet nice life, instead of dealing with this shit…