von Alberto ADV.
Hi, if everyone wants to know, we think we solved the problems.
We used these commands:
DELETE FROM mdl_question_bank_entries
WHERE id IN (
SELECT qv.questionbankentryid
FROM mdl_question_versions qv
JOIN mdl_question q ON q.id = qv.questionid
WHERE q.qtype = 'random'
)
DELETE FROM mdl_question_versions qv
WHERE questionid IN (
SELECT id FROM mdl_question q WHERE q.qtype = 'random'
)
DELETE FROM mdl_question WHERE qtype = 'random'
Note, you can get some confidence that nothing is referring to these random questions by running the following 2 queries, which should both return 0 rows.
SELECT *
FROM mdl_question_attempts qa
JOIN mdl_question q ON q.id = qa.questionid
WHERE q.qtype = 'random'
SELECT *
FROM mdl_question_references qr
JOIN mdl_question_versions qv ON qv.questionbankentryid = qr.questionbankentryid
JOIN mdl_question q ON q.id = qv.questionid
WHERE q.qtype = 'random'
The asynchronous copy task went from taking 2 hours to taking 40 seconds, from 5.890.633 reading and 3.293.262 writing in 140.549 reading and 57.718 writing.
I hope that in the future versions of moodle there will be some kind of cleanup (and safely) task to purge:
- unwanted random question imported from old courses
- blank question bank
And some kind of report that can be used to find and delete unusued questions or unusued question banks entirely.
Thanks
We used these commands:
DELETE FROM mdl_question_bank_entries
WHERE id IN (
SELECT qv.questionbankentryid
FROM mdl_question_versions qv
JOIN mdl_question q ON q.id = qv.questionid
WHERE q.qtype = 'random'
)
DELETE FROM mdl_question_versions qv
WHERE questionid IN (
SELECT id FROM mdl_question q WHERE q.qtype = 'random'
)
DELETE FROM mdl_question WHERE qtype = 'random'
Note, you can get some confidence that nothing is referring to these random questions by running the following 2 queries, which should both return 0 rows.
SELECT *
FROM mdl_question_attempts qa
JOIN mdl_question q ON q.id = qa.questionid
WHERE q.qtype = 'random'
SELECT *
FROM mdl_question_references qr
JOIN mdl_question_versions qv ON qv.questionbankentryid = qr.questionbankentryid
JOIN mdl_question q ON q.id = qv.questionid
WHERE q.qtype = 'random'
The asynchronous copy task went from taking 2 hours to taking 40 seconds, from 5.890.633 reading and 3.293.262 writing in 140.549 reading and 57.718 writing.
I hope that in the future versions of moodle there will be some kind of cleanup (and safely) task to purge:
- unwanted random question imported from old courses
- blank question bank
And some kind of report that can be used to find and delete unusued questions or unusued question banks entirely.
Thanks