Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-39443 META: OU Moodle 2.4 performance tuning
  3. MDL-39723

Most pages make 2 unnecessary course queries

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.5.1
    • 2.5
    • Libraries
    • MOODLE_25_STABLE
    • MOODLE_25_STABLE
    • MDL-39723-master
    • Hide

      1. Look at a course page. Verify it still appears OK without error.
      2. Look at a forum view page. Verify it still appears OK without error.

      Optional extra section (if you can easily switch between branches)
      3. Turn on the 'perfdebug' option.
      4. Change to a branch without this patch.
      5. Load the course view page. Look at the database query counts. Reload a few times to get the minimum number. (It will depend on server settings and course content. On my test, that number was 60.)
      6. Change to a branch that includes this patch.
      7. Repeat #5. Verify that the number has now decreased by 2. (On my server, 58.)

      Show
      1. Look at a course page. Verify it still appears OK without error. 2. Look at a forum view page. Verify it still appears OK without error. Optional extra section (if you can easily switch between branches) 3. Turn on the 'perfdebug' option. 4. Change to a branch without this patch. 5. Load the course view page. Look at the database query counts. Reload a few times to get the minimum number. (It will depend on server settings and course content. On my test, that number was 60.) 6. Change to a branch that includes this patch. 7. Repeat #5. Verify that the number has now decreased by 2. (On my server, 58.)

      The course format code makes an unnecessary get_record call on the course table for courses which are normally already loaded in memory: $COURSE and $SITE.

      Although this is only likely to be two queries per page, it is still worth saving two queries. Additionally, course table rows are quite large (typically in the 100KB range, with our largest being over a megabyte) so the queries may waste a bit of resources.

      It's only the course format that does this on every page. However, as this may be a more general issue, I suggest creating a get_course API to do it properly.

      I suggest this might be suitable for 2.5.1, or 2.6 if necessary. (At the OU we have already solved this problem because we use a custom database driver so we put the logic into there.)

            quen Sam Marshall
            quen Sam Marshall
            Rajesh Taneja Rajesh Taneja
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Adrian Greeve Adrian Greeve
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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