Skip to content

Commit

Permalink
MDL-77965 Filter columns to only those used
Browse files Browse the repository at this point in the history
This stops Oracle from having to try to compare text columns.
  • Loading branch information
NeillM committed Feb 22, 2024
1 parent ee77acd commit 585f8bb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mod/quiz/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,17 @@ protected static function export_quiz_attempts(approved_contextlist $contextlist
$userid
);

// The layout column causes the union in the following query to fail on Oracle, it also appears to not be used.
// So we can filter the return values to be only those used to generate the data, this will have the benefit
// improving performance on all databases as we will no longer be returning a text field for each row.
$attemptfields = 'qa.id, qa.quiz, qa.userid, qa.attempt, qa.uniqueid, qa.preview, qa.state, qa.timestart, ' .
'qa.timefinish, qa.timemodified, qa.timemodifiedoffline, qa.timecheckstate, qa.sumgrades, ' .
'qa.gradednotificationsenttime';

$sql = "SELECT
c.id AS contextid,
cm.id AS cmid,
qa.*
$attemptfields
FROM {context} c
JOIN {course_modules} cm ON cm.id = c.instanceid AND c.contextlevel = :contextlevel1
JOIN {modules} m ON m.id = cm.module AND m.name = 'quiz'
Expand All @@ -508,7 +515,7 @@ protected static function export_quiz_attempts(approved_contextlist $contextlist
SELECT
c.id AS contextid,
cm.id AS cmid,
qa.*
$attemptfields
FROM {context} c
JOIN {course_modules} cm ON cm.id = c.instanceid AND c.contextlevel = :contextlevel2
JOIN {modules} m ON m.id = cm.module AND m.name = 'quiz'
Expand Down

0 comments on commit 585f8bb

Please sign in to comment.