Hello all.
We are managing a moodle with mdl_lesson_branch table composed by 12685665 rows.
In the process of importing a course or copying courses with
lesson pages, the performance is poor and takes more than 30 minutes, it blocks the normal performance of the tool. Performance is worst after the upgrade from 3.9 to 3.11.
We reviewed the code and the cause is the execution of below code from mod/
lesson/backup/moodle2/restore_lesson_stepslib.php:
// Replay the upgrade step 2015032700. |
// Delete any orphaned lesson_branch record. |
if ($DB->get_dbfamily() === 'mysql') { |
$sql = "DELETE {lesson_branch} |
ON {lesson_branch}.pageid = {lesson_pages}.id |
WHERE {lesson_pages}.id IS NULL"; |
$sql = "DELETE FROM {lesson_branch} |
SELECT 'x' FROM {lesson_pages} |
WHERE {lesson_branch}.pageid = {lesson_pages}.id)"; |
$DB->execute($
sql);
The sentence takes about 60 seconds in our
database.
Does anyone know if this SQL request can be safely improved or cleaned from the code.
We are considering deleting this query and planning a
nightly execution to avoid any problems with orphaned lesson branch records.
Many thanks in advance.