render :json => {
"playlist" => playlist_description,
"songs" => @playlist.songs.as_json(:include => {:playlist_songs => {:only => [:id, :position]}})
}
The above code results in 1+N queries to the database, one to load playlist_songs for each song. The playlist is preloaded in @playlist.
This is so slow, how can I optimize?