Optimized song retrieval from database with joins