MDL-63103 filebrowser: Speed up finding activities with files
Before this change the query examined at every course_module record in the context table. With this change we use the course_modules table to more efficiently find all the activities in the course, which means that many less records in the context table need to be examined.
This commit is contained in:
@@ -528,16 +528,15 @@ class file_info_context_course extends file_info {
|
||||
$params1 = ['contextid' => $this->context->id,
|
||||
'emptyfilename' => '.',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'depth' => $this->context->depth + 1,
|
||||
'pathmask' => $this->context->path . '/%'];
|
||||
'course' => $this->course->id];
|
||||
$sql1 = "SELECT ctx.id AS contextid, f.component, f.filearea, f.itemid, ctx.instanceid AS cmid, " .
|
||||
context_helper::get_preload_record_columns_sql('ctx') . "
|
||||
FROM {files} f
|
||||
INNER JOIN {context} ctx ON ctx.id = f.contextid
|
||||
INNER JOIN {course_modules} cm ON cm.id = ctx.instanceid
|
||||
WHERE f.filename <> :emptyfilename
|
||||
AND ctx.contextlevel = :contextlevel
|
||||
AND ctx.depth = :depth
|
||||
AND " . $DB->sql_like('ctx.path', ':pathmask') . " ";
|
||||
AND cm.course = :course
|
||||
AND ctx.contextlevel = :contextlevel";
|
||||
$sql3 = ' GROUP BY ctx.id, f.component, f.filearea, f.itemid, ctx.instanceid,
|
||||
ctx.path, ctx.depth, ctx.contextlevel
|
||||
ORDER BY ctx.id, f.component, f.filearea, f.itemid';
|
||||
|
||||
Reference in New Issue
Block a user