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

pre-cache active filters for course categories to significantly reduce database queries

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Won't Fix
    • Affects Version/s: 2.2.5, 2.3, 2.4
    • Fix Version/s: None
    • Component/s: Filters, Performance
    • Testing Instructions:
      Hide
      • have 500 course categories
      • enable multilang filter for content and headings (which allows course category names to be multilingual)
      • go to course/index.php or course/category.php
      • with page-bottom stats enabled, see how many db queries it takes to load these pages
      • apply the commit, and retest. Db queries should be reduced by approximately the number of course categories.
      Show
      have 500 course categories enable multilang filter for content and headings (which allows course category names to be multilingual) go to course/index.php or course/category.php with page-bottom stats enabled, see how many db queries it takes to load these pages apply the commit, and retest. Db queries should be reduced by approximately the number of course categories.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Story Points:
      20
    • Sprint:
      FRONTEND Sprint 7

      Description

      On Moodles that have a lot of course categories, and a filter enabled for content and headings (e.g. multilang), there are currently excessively many database queries being made (e.g. 1 per course category). For example, if you have 500 course categories, which is often the case for large institutions, you will have > 500 queries on course/index.php or course/category.php.

      The database queries are caused by a call to get the context instance for each course category.

      I've coded something in the branch https://github.com/brki/moodle/tree/mdl23-preload-filters-for-course-categories . The commit https://github.com/brki/moodle/commit/da23cce06d7edbd2cad43ba9c25396dcf5bfac35 preloads all the course category context instances for course/index.php and course/category.php. This reduces the database queries significantly (it makes two database queries to get all of the course category contexts instead of one for every course category).

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: