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

/course/index.php "find any orphan courses" if statement takes a LOT of sql querries and time to run when running with large number of courses

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.8, 1.8.1, 1.8.2
    • Fix Version/s: 1.9
    • Component/s: Course
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      At around line #276 of /course/index.php the if statement is not efficient and could take a LONG time (and lots of sql querries) to complete, hence make the loading of course listing VERY slow when have large number of courses (e.g. 40000 courses)

      /// Find any orphan courses that don't yet have a valid category and set to default
      if ($courses = get_courses(NULL,NULL,'c.id, c.category, c.sortorder, c.visible')) {
      foreach ($courses as $course) {
      if ($course->category and !isset($categories[$course->category]))

      { set_field('course', 'category', $default, 'id', $course->id); }

      }
      }

      We commented this out on our pilot testing server and that helps a lot. Eventually we should look at a more efficient way to check with orphan courses that don't have a valid category..

        Attachments

          Activity

            People

            Assignee:
            martinlanghoff Martín Langhoff
            Reporter:
            chuang Wen Hao Chuang
            Tester:
            Petr Skoda
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              3/Mar/08