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

Slow upgrade_grade_item_fix_sortorder

    Details

    • Testing Instructions:
      Hide

      Follow testing instructions from MDL-41062 (you will need an initial instance older than 23/Jan/14 )

      Show
      Follow testing instructions from MDL-41062 (you will need an initial instance older than 23/Jan/14 )
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull from Repository:

      Description

      The upgrade_grade_item_fix_sortorder function is still much too slow, even after MDL-43946.

      On one of our sites, it appears this will take at least several hours to finish (I didn't let it go, just guessing from what progress it made after 30 minutes...) all the while blocking much happening with grade items.

      The problem appears to be that when courses have a large amount of grade items (in our case some with 4000 and more) the related rows are updated thousands of times; besides the O(N*N) time complexity there is a huge bloating of the table during the transaction which causes its own problems.

      My patch moves this update loop for a given course to memory in PHP, then writes the updates back out when that course is finished. This results in only O(N) rows updated, and completes in a few seconds on a problematic dataset.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    12/May/14