Moodle

Bulk upload user form costs 16,000 database queries with 165 users course/group enrolments

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.9.4
  • Fix Version/s: STABLE backlog
  • Component/s: Performance
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE

Description

I have some sample data & when uploading 165 user records with this sort of thing:

username,course1,course2,course3,course4,course5,group1,group2,group3,group4,group5
myusername,9.1,9.2,9.3,9.4,9.5,9H,9H,9H,9H,9H
myusername2,9.1,9.2,9.3,9.4,9.5,9H,9H,9H,9H,9H

Its costing 16,000 database queries. This makes the upload unusuable.

Need to investigate and improve what is causing this.

Issue Links

Activity

Hide
Dan Poltawski added a comment -

Looks like this is the major culprit:

// make sure user is enrolled into course before adding into groups
if (!has_capability('moodle/course:view', $coursecontext, $user->id, false)) { $upt->track('enrolments', get_string('addedtogroupnotenrolled', '', $gname), 'error'); continue; }

Some sort of course participant cache would help here

Show
Dan Poltawski added a comment - Looks like this is the major culprit: // make sure user is enrolled into course before adding into groups if (!has_capability('moodle/course:view', $coursecontext, $user->id, false)) { $upt->track('enrolments', get_string('addedtogroupnotenrolled', '', $gname), 'error'); continue; } Some sort of course participant cache would help here
Hide
Dan Poltawski added a comment -

Completely untested 'canview' cache. Wouldn't be strictly correct for view permisison

Show
Dan Poltawski added a comment - Completely untested 'canview' cache. Wouldn't be strictly correct for view permisison
Hide
Petr Škoda (skodak) added a comment -

Enrolling is EXTREMELY expensive, this is normal and very hard to fix without the enrolment code rewrite

Show
Petr Škoda (skodak) added a comment - Enrolling is EXTREMELY expensive, this is normal and very hard to fix without the enrolment code rewrite
Hide
Dan Poltawski added a comment -

Agreed - however in this particular case I think we can improve performance to be better than 100 queries per user because it makes the feature unusable with tiny amounts of users.

Show
Dan Poltawski added a comment - Agreed - however in this particular case I think we can improve performance to be better than 100 queries per user because it makes the feature unusable with tiny amounts of users.
Hide
Petr Škoda (skodak) added a comment -

looks like you are volunteering to do the testing and merging :-D

Show
Petr Škoda (skodak) added a comment - looks like you are volunteering to do the testing and merging :-D
Hide
Dan Poltawski added a comment -

heh

Show
Dan Poltawski added a comment - heh

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: