Hi,
I am trying to restore a course, it contains a lot of questions, and it takes a long time to restore, and it turns out that there is a bad performance query problem,
the Course retrieval includes SQL Update with bad performance, does not use an index, scans thousands of records, and causes a delay of 40 percent of the course retrieval time
the query from :



"moodle/backup/moodle2/restore_stepslib.php "
class restore_move_module_questions_categories
function define_execution()
//Update the context id of any tags applied to any questions in these categories.

The update Query is executed many times, each time ; reads (full table scan ) 231282 records, and it consumes 100% of the CPU, and takes about 7 milliseconds each time.
the query from mariadb log"

I have rewritten the Update Query as following; so that, following the index, the execution time is greatly reduced, the process becomes fast, and it does not waste time:

Hope; developers check the query and find a proper solution!!