Moodle

Implement workaround for MySQL bug

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.9.5
  • Fix Version/s: None
  • Component/s: Libraries, Performance
  • Labels:
    None
  • Environment:
    Ubuntu Linux 9.04, MySQL 5.1.35 InnoDB engine
  • Database:
    MySQL
  • Difficulty:
    Moderate
  • Affected Branches:
    MOODLE_19_STABLE

Description

If InnoDB is used the query like in course/lib.php is a really slow query:

SELECT * FROM mdl_log WHERE time > 1244979700 AND course = 1015 AND module = 'course' AND (action = 'add mod' OR action = 'update mod' OR action = 'delete mod') ORDER BY id ASC;

This might be referred to http://bugs.mysql.com/bug.php?id=28404 and http://bugs.mysql.com/bug.php?id=36259. The work around is simply FORCE INDEX (Thanks to Valeriy Kravchuk, MySQL Principal Support Engineer). The workaround I have done with course/lib.php is

// ---------------ORIGINAL CODE---------------
// $logs = get_records_select('log', "time > $timestart AND course = $course->id AND
// module = 'course' AND
// (action = 'add mod' OR action = 'update mod' OR action = 'delete mod')",
// "id ASC");

$sqllogs = "SELECT * FROM " . $CFG->prefix . "log FORCE INDEX (coursemoduleaction) WHERE
time > $timestart AND course = $course->id AND module = 'course' AND
(action = 'add mod' OR action = 'update mod' OR action = 'delete mod') ORDER BY id ASC";
$logs = get_recordset_sql($sqllogs);

Sorry! I am not good in programming.

Activity

Hide
Petr Škoda (skodak) added a comment -

sending a test file for Jordan

Show
Petr Škoda (skodak) added a comment - sending a test file for Jordan
Hide
Jordan Tomkinson added a comment -

performance test patch

Show
Jordan Tomkinson added a comment - performance test patch
Hide
Jordan Tomkinson added a comment -

I dont see any real difference here, using moodle.org's database i see:

array
3 => float 0.001271
2 => float 0.00086200000000003
1 => float 0.00078899999999993

Indicating the UNION is actually slower than the original query :/
Anyone else want to test this out?

Show
Jordan Tomkinson added a comment - I dont see any real difference here, using moodle.org's database i see: array 3 => float 0.001271 2 => float 0.00086200000000003 1 => float 0.00078899999999993 Indicating the UNION is actually slower than the original query :/ Anyone else want to test this out?

People

Vote (0)
Watch (5)

Dates

  • Created:
    Updated: