Issue Details (XML | Word | Printable)

Key: MDL-7899
Type: Sub-task Sub-task
Status: Resolved Resolved
Resolution: Duplicate
Priority: Major Major
Assignee: Eloy Lafuente (stronk7)
Reporter: Samuli Karevaara
Votes: 0
Watchers: 1
Operations

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

A huge optimization to user_files_check_backup() (with patch)

Created: 12/Dec/06 06:55 PM   Updated: 25/Apr/08 09:40 AM
Return to search
Component/s: Backup
Affects Version/s: 1.6.3, 1.6.4
Fix Version/s: None

File Attachments: 1. Text File backuplib.php.patch (2 kB)

Issue Links:
Dependency
 

Participants: Dan Marsden, Eloy Lafuente (stronk7) and Samuli Karevaara
Security Level: None
Resolved date: 25/Apr/08
Affected Branches: MOODLE_16_STABLE


 Description  « Hide
In our environment backing up empty courses halted for quite a while on the "calculating items to backup" page, so I investigated:

Currently the function user_files_check_backup() gets the list of user directories and then queries the backup_ids table to see if this user is needed in the backup. In our environment this generates _thousands_ of database queries even if the course is empty or has just a couple of users in it.

In the attached patch I'm querying all of the users that are needed in the backup with one query to a PHP array, then instead of going to the database for _every user_ that has a profile picture, I'm just checking against that array. Instead of ~3000 queries I get just one.

Also, I didn't see a need for the strtok() as the directories are the userids already... Or is there a "/" there in some filesystems? I tested this both in Windows and Linux, no problems.

The function in question seems to be unchanged in 1.7 so this patch might apply there too. The users are fetched from the backup_ids table and not from the user_students and user_teachers tables.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Petr Skoda made changes - 09/Mar/08 09:38 PM
Field Original Value New Value
Parent MDL-13847 [ 25343 ]
Issue Type Improvement [ 4 ] Sub-task [ 5 ]
Petr Skoda made changes - 09/Mar/08 09:38 PM
Assignee Eloy Lafuente (stronk7) [ stronk7 ] Petr Skoda [ skodak ]
Dan Marsden made changes - 09/Apr/08 05:55 AM
Link This issue will be resolved by MDL-14269 [ MDL-14269 ]
Dan Marsden made changes - 25/Apr/08 07:46 AM
Link This issue will be resolved by MDL-14550 [ MDL-14550 ]
Eloy Lafuente (stronk7) made changes - 25/Apr/08 09:40 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Duplicate [ 3 ]
Assignee Petr Skoda [ skodak ] Eloy Lafuente (stronk7) [ stronk7 ]