Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
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.
sending a test file for Jordan