Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-37403

Improve query which is updating question_attempts table.

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 2.2.6
    • Quiz
    • None
    • MOODLE_22_STABLE

      One of our sites is seeing long-running queries which take various forms like this:

      UPDATE mdl_question_attempts SET maxmark = $X WHERE questionusageid IN (SELECT quiza.uniqueid FROM mdl_quiz_attempts quiza WHERE quiza.quiz = '$Y') AND slot = '$Z'
      

      The subquery frequently returns an empty set, but MySQL will spend multiple minutes running this query as is examines the over 15M rows in this table when updates are not even necessary.

      Please eliminate the need for a subquery here to improve performance of this query.

            timhunt Tim Hunt
            dakota.duff Dakota Duff
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.