Skip to content

Slow query execution when an answer in a plan is saved #3598

Description

@gjacob24

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])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions