Issue Details (XML | Word | Printable)

Key: MDL-18314
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Dan Poltawski
Reporter: Dan Poltawski
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

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

Created: 19/Feb/09 09:17 PM   Updated: 21/Oct/09 04:17 PM
Return to search
Component/s: Performance
Affects Version/s: 1.9.4
Fix Version/s: 1.9.7

File Attachments: 1. Text File 0001-MDL-18314-hacky-proof-of-concept-capability-cache.patch (2 kB)

Issue Links:
Relates
 

Participants: Dan Poltawski and Petr Skoda
Security Level: None
Affected Branches: MOODLE_19_STABLE
Fixed Branches: MOODLE_19_STABLE


 Description  « Hide
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.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Dan Poltawski added a comment - 19/Feb/09 09:36 PM
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


Dan Poltawski added a comment - 19/Feb/09 10:06 PM
Completely untested 'canview' cache. Wouldn't be strictly correct for view permisison

Petr Skoda added a comment - 19/Feb/09 10:49 PM
Enrolling is EXTREMELY expensive, this is normal and very hard to fix without the enrolment code rewrite

Dan Poltawski added a comment - 19/Feb/09 10:57 PM
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.

Petr Skoda added a comment - 19/Feb/09 11:01 PM
looks like you are volunteering to do the testing and merging :-D

Dan Poltawski added a comment - 19/Feb/09 11:14 PM
heh