]> git.mjollnir.org Git - moodle.git/commitdiff
Close Bug #5670 - get_courses_page() - remove costly and redundant DISTINCT
authormartinlanghoff <martinlanghoff>
Tue, 18 Jul 2006 04:39:01 +0000 (04:39 +0000)
committermartinlanghoff <martinlanghoff>
Tue, 18 Jul 2006 04:39:01 +0000 (04:39 +0000)
get_courses_page() uses get_records_sql() which means that it will actually
break if the first field requested isn't c.id. This in turn means that
the DISTINCT is not needed at all.

So let's go fast again!

lib/datalib.php

index 264e278ed252db79b4ab0f44fe35962e728d7f56..15434e7e4d297f7ca82df36dba09eeff8100460e 100644 (file)
@@ -2185,7 +2185,7 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c
 
     $totalcount = count_records_sql("SELECT COUNT(DISTINCT c.id) FROM $selectsql");
 
-    return get_records_sql("SELECT DISTINCT $fields FROM $selectsql ".((!empty($sort)) ? "ORDER BY $sort" : "")." $limit");
+    return get_records_sql("SELECT $fields FROM $selectsql ".((!empty($sort)) ? "ORDER BY $sort" : "")." $limit");
 }