Issue Details (XML | Word | Printable)

Key: MDL-19646
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: moodle.com
Reporter: Denpong Soodphakdee
Votes: 0
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Implement workaround for MySQL bug

Created: 28/Jun/09 08:59 PM   Updated: 28/Jun/09 08:59 PM
Return to search
Component/s: Lib, Performance
Affects Version/s: 1.9.5
Fix Version/s: None

Environment: Ubuntu Linux 9.04, MySQL 5.1.35 InnoDB engine

Database: MySQL
Participants: Denpong Soodphakdee and moodle.com
Security Level: None
Difficulty: Moderate
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
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.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.