Moodle

grade_get_exceptions query improvement

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.5.3
  • Fix Version/s: 1.9.5
  • Component/s: Gradebook
  • Labels:
    None
  • Environment:
    All
  • Database:
    Any
  • Affected Branches:
    MOODLE_15_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

Query should be

$sql = SELECT e.id, e.userid, gi.cminstance, gi.modid, c.name as catname, mm.name as modname

FROM {$CFG->prefix}grade_exceptions e,

{$CFG->prefix}grade_item gi,

{$CFG->prefix}grade_category c,

{$CFG->prefix}modules mm

WHERE e.courseid=$course

AND gi.id = e.grade_itemid

AND c.id = gi.category

AND gi.modid=mm.id;

The old one was unnecesarily slowing down (to a halt) a gradebook with a lot of exceptions.

Activity

Hide
Anthony Borrow added a comment -

This bug needs to be assigned so that the query efficiency can be evaluated. Currently we have:

function grade_get_grade_item_exceptions($id) {

global $CFG, $course;

$contextlists = get_related_contexts_string(get_context_instance(CONTEXT_COURSE, $course->id));

$sql = "SELECT ge.id, ge.userid
FROM {$CFG->prefix}grade_exceptions ge,
{$CFG->prefix}role_assignments ra
WHERE grade_itemid = $id
AND ge.userid = ra.userid
AND ra.contextid $contextlists";

return get_records_sql($sql);
}

I am hoping that some of what was learned from working on speeding up the get_my_courses function in MDL-7416 can help out here as well. Peace - Anthony

Show
Anthony Borrow added a comment - This bug needs to be assigned so that the query efficiency can be evaluated. Currently we have: function grade_get_grade_item_exceptions($id) { global $CFG, $course; $contextlists = get_related_contexts_string(get_context_instance(CONTEXT_COURSE, $course->id)); $sql = "SELECT ge.id, ge.userid FROM {$CFG->prefix}grade_exceptions ge, {$CFG->prefix}role_assignments ra WHERE grade_itemid = $id AND ge.userid = ra.userid AND ra.contextid $contextlists"; return get_records_sql($sql); } I am hoping that some of what was learned from working on speeding up the get_my_courses function in MDL-7416 can help out here as well. Peace - Anthony
Hide
Petr Škoda (skodak) added a comment -

please upgrade to latest 1.9.x, 1.5x is not supported at all
thanks

Show
Petr Škoda (skodak) added a comment - please upgrade to latest 1.9.x, 1.5x is not supported at all thanks

People

Vote (3)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: