Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6815

Course restore includes a bad performance SQL Update query

$
0
0
by khaled flihan.  

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 

​my moodle ver:  Moodle 4.2 (Build: 20230424)
​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.

bad query perfomramnce

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" 
execution MySQL 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:

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

Viewing all articles
Browse latest Browse all 6815

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>