Optimize deletion of tracks on a rescan - part 2

Replace some of the expensive DBIC code with native SQL