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

/enrol/users.php loads in 20 s. in any course (Postgres)

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create 11,000 cohorts.
      2. This can be done by uploading the cohort.csv file through [Site administration  ► Users  ► Accounts  ► Cohorts  ► Upload cohorts].
      3. The next thing to do is enter users into each of the cohorts. I recommend using test.php (or something similar).
        • I commented out all of the code for creating logs (line 168 - 176) in cohort.lib - cohort_add_member() to speed things along and I suggest that you do the same.
      4. Now go to an enrolement page of a course [Course administration ► Users  ► Enrolled users].
      5. Check that there are no errors. The page should load in a resonable time (this is dependant on the system and the database being used).
      6. Rinse and repeat with each of the databases that we support.
      7. After this you are out of my control and are free to do as you wish.
      Show
      Create 11,000 cohorts. This can be done by uploading the cohort.csv file through [Site administration  ► Users  ► Accounts  ► Cohorts  ► Upload cohorts] . The next thing to do is enter users into each of the cohorts. I recommend using test.php (or something similar). I commented out all of the code for creating logs (line 168 - 176) in cohort.lib - cohort_add_member() to speed things along and I suggest that you do the same. Now go to an enrolement page of a course [Course administration ► Users  ► Enrolled users] . Check that there are no errors. The page should load in a resonable time (this is dependant on the system and the database being used). Rinse and repeat with each of the databases that we support. After this you are out of my control and are free to do as you wish.
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-51241-master
    • Sprint:
      Team Both Sprint 1

      Description

      Opening the page /enrol/users.php takes about 20 seconds (time for the main query, not including the assets).
      This Moodle instance uses a dedicated Postgres 9.4 server.
      There are about 11,000 cohorts defined globally.
      Another instance, with more cohorts, with the same Moodle 2.9 code but using MariaDB, displays the same page in less than 1 second.

      After some profiling (XHProf) and slow query logging (pg_stat_statements), the culprit is the query that counts the users enrolled directly and through cohorts, in the PHP function cohort_get_available_cohorts() of cohort/lib.php.

        Attachments

        1. cohort.csv
          215 kB
        2. test.php
          0.4 kB

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Nov/15