Instead of the IN, see if this is better: AND (SELECT count(*) FROM albumjoin aj WHERE aj.album = album.id) BETWEEN 15 AND 25.
Instead of the IN, see if this is better: AND (SELECT count(*) FROM albumjoin aj WHERE aj.album = album.id) BETWEEN 15 AND 25.