Problem: When a user edits an answer in a plan, it takes 30-50 seconds to save and this is causing the DMPonline service to crash, because we have a large amount of plans.
Cause: The query in answers_controller.rb is retrieving all the answers with question ID 'YYY' first and then filtered the results with the plan ID 'XXX'.
answers_controller.rb (lines 89-96)
@plan = Plan.includes(
sections: {
questions: %i[
answers
question_format
]
}
).find(p_params[:plan_id])
Problem: When a user edits an answer in a plan, it takes 30-50 seconds to save and this is causing the DMPonline service to crash, because we have a large amount of plans.
Cause: The query in
answers_controller.rbis retrieving all the answers with question ID 'YYY' first and then filtered the results with the plan ID 'XXX'.answers_controller.rb (lines 89-96)