Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.4.6, 3.5.3, 3.6.1
-
MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE
-
MOODLE_35_STABLE, MOODLE_36_STABLE
-
Description
MDL-51412 addressed the issue by adding index to qtype for mdl_question which optimises the query used during restore. However, this code may need optimisation
line 97 of question/type/essay/backup/moodle2/restore_qtype_essay_plugin.class.php
// code placeholder
|
protected function after_execute_question() { |
global $DB;
|
|
|
$essayswithoutoptions = $DB->get_records_sql("
|
SELECT *
|
FROM {question} q
|
WHERE q.qtype = ?
|
AND NOT EXISTS (
|
SELECT 1 |
FROM {qtype_essay_options}
|
WHERE questionid = q.id
|
)
|
", array('essay')); |
For very large sites, this takes a lot.
// code placeholder
|
SELECT *
|
FROM mdl_question q
|
WHERE q.qtype = 'essay' |
AND NOT EXISTS (
|
SELECT 1 |
FROM mdl_qtype_essay_options
|
WHERE questionid = q.id
|
);
|
QUERY PLAN
|
----------------------------------------------------------------------------------------------
|
Hash Anti Join (cost=83414.77..1247847.52 rows=1061038 width=391) |
Hash Cond: (q.id = mdl_qtype_essay_options.questionid)
|
-> Bitmap Heap Scan on mdl_question q (cost=25571.59..1057620.12 rows=1128132 width=391) |
Recheck Cond: ((qtype)::text = 'essay'::text) |
-> Bitmap Index Scan on mdl_ques_qty_ix (cost=0.00..25289.55 rows=1128132 width=0) |
Index Cond: ((qtype)::text = 'essay'::text) |
-> Hash (cost=40369.86..40369.86 rows=1064986 width=8) |
-> Seq Scan on mdl_qtype_essay_options (cost=0.00..40369.86 rows=1064986 width=8) |
(8 rows) |
This looks to set defaults on broken question records in case it has restored any. However, it looks to end up looking at"all" questions to do that. Rather than just inspecting the restored ones.