optimized learning_tasks query