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

Multiple occurrences of the editor on the same page cause excessive db queries

    XMLWordPrintable

Details

    • Any
    • MOODLE_21_STABLE
    • MDL-29831-master
    • Moderate
    • Hide

      Enable perf to footer for ease
      From Home as administrator:

      • Settings -> Front Page Settings -> Questions
      • Select 'Create a new Question'
      • Choose 'Multiple Choice'
      • Note number of queries
      • Refresh page
      • Note number of queries
      • From the breadcrumbs, choose 'Edit question'
      • Select 'Create a new Question'
      • Choose 'True/False'
      • Note number of queries
      • Refresh page
      • Note number of queries

      Enable an additional Repository plugin (I chose URL Downloader with default settings)
      Repeat

      Show
      Enable perf to footer for ease From Home as administrator: Settings -> Front Page Settings -> Questions Select 'Create a new Question' Choose 'Multiple Choice' Note number of queries Refresh page Note number of queries From the breadcrumbs, choose 'Edit question' Select 'Create a new Question' Choose 'True/False' Note number of queries Refresh page Note number of queries Enable an additional Repository plugin (I chose URL Downloader with default settings) Repeat

    Description

      On a page with multiple copies of the editor (e.g. when adding a new multichoice question), an excessive number of database reads are seen.

      When the editor is inserted into a page, lib/form/editor.php::MoodleQuickForm_editor->toHtml() is called
      This in turn calls initialise_filepicker once for each type of media plugin - e.g. advimage, moodlemedia, and advlink
      The initialise_filepicker() function in turn calls repository::get_instances which generates a set of queries for each of the repository plugins.

      As an example on my default 2.1 install:

      First editor: 57 queries
      Subsequent editors: 54 queries each
      Total queries for 17 editors = 57 + (54 * 16) = 921

      Enabling an additional repository plugin (URL downloader) changes these numbers

      First editor: 69 queries
      Subsequent editors: 66 queries each
      Total queries for 17 editors = 69 + (66 * 16) = 1125

      (Note, I loaded the page twice after adding enabling additional repository plugins)

      We should see if it's possible to cache the results for some of these queries. They're mostly of the nature:

      SELECT * FROM mdl_repository_instances WHERE id = $1 [array ( 0 => '1', )]
      SELECT * FROM mdl_repository_instance_config WHERE instanceid = $1 [array ( 0 => '1', )]
      SELECT * FROM mdl_repository WHERE id = $1 [array ( 0 => '1', )]
      SELECT name,value FROM mdl_config_plugins WHERE plugin = $1 [array ( 0 => 'local', )]

      This is seen for any user (not just administrators). The question component is not at fault, but provides a handy set of editors to try.

      Attachments

        Issue Links

          Activity

            People

              moodle.com Moodle HQ
              dobedobedoh Andrew Lyons
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Clockify

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