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

Slow upgrade_grade_item_fix_sortorder

    XMLWordPrintable

Details

    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_25_STABLE, MOODLE_26_STABLE
    • 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 )

    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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tlevi Tony Levi
              Damyon Wiese Damyon Wiese
              Damyon Wiese Damyon Wiese
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Matteo Scaramuccia, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo, Matteo Scaramuccia, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                12/May/14