I will try to answer to your questions:
- The only reason why i need the queue table is to avoid to select duplicates when i generate the playlist from the rotation and i need an exact copy of the playlist that i have in the memory.
It's not only about deleting the playing track, but when a track is inserted to a specific position in the playlist, or they are drag & dropped, it would be far more complicated to reorder them in the queue table than truncate the table and then inserting a fresh copy of the playlist.
In order to sync them i would need to use more delete/insert commands on the table and as far as i know
TRUNCATE is faster because it doesn't keep any logs.
- For this test i tried another method to avoid duplicates and to be honest i don't understand why here is working flawlessly and there not. If i use the LEFT JOIN i can only exclude artists that are named exactly the same, which makes our existing featured artist separation method inefficient. Like i said before the featured artists are marked as played only when the track is actually played.
But what happens when the track is not played yet. Let's say that the first artist from the playlist is "Pitbull f. Danny Mercer" and the Auto DJ needs to add more tracks. If it will use the existing LEFT JOIN to see if the artist it's already in the queue table "Pitbull f. G.R.L." will be a valid result because this exact artist is not found, so we will end up with a duplicate artist.
So i tried a different approach and i removed the join and each time when i select a track, i split the featured artists and i update the "tartist_played" with the current date and time and when i select a new track i order the results also by the "tartist_played" ASC.
Maybe it's not the best method, but that's why i said that it's a test...
PS: Do you have rotation entries without repeat rules unchecked beside jingles?