--- course/lib.php	2010-03-30 14:10:36.000000000 +0800
+++ course/lib.php	2010-03-30 12:58:44.000000000 +0800
@@ -885,10 +885,58 @@
 
     $changelist = array();
 
-    $logs = get_records_select('log', "time > $timestart AND course = $course->id AND
+/*    $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");
+                               "id ASC");*/
+
+    //old way
+    $sqllogs1 = "SELECT *
+                   FROM {$CFG->prefix}log
+                  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";
+
+    // mysql hack for comparison
+    $sqllogs2 = "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";
+
+    //union
+    $sqllogs3 = "SELECT l.*
+                   FROM (SELECT *
+                           FROM {$CFG->prefix}log
+                          WHERE course = $course->id AND module = 'course' AND action = 'add mod' AND time > $timestart
+
+                         UNION
+
+                         SELECT *
+                           FROM {$CFG->prefix}log
+                          WHERE course = $course->id AND module = 'course' AND action = 'update mod' AND time > $timestart
+
+                         UNION
+
+                         SELECT *
+                           FROM {$CFG->prefix}log
+                          WHERE course = $course->id AND module = 'course' AND action = 'delete mod' AND time > $timestart
+                        ) l
+                   ORDER BY id ASC";
+
+    $res = array();
+    $start = microtime();
+    $logs = get_records_sql($sqllogs3);
+    $res[3] = microtime()-$start;
+    $start = microtime();
+    $logs = get_records_sql($sqllogs2);
+    $res[2] = microtime()-$start;
+    $start = microtime();
+    $logs = get_records_sql($sqllogs1);
+    $res[1] = microtime()-$start;
+    var_dump($res);
 
     if ($logs) {
         $actions  = array('add mod', 'update mod', 'delete mod');
