Improve performance by changing query

Issue #44 new
Former user created an issue

The plugin is loading very slowly for large sites.

The performance can be improved by changing the following code in blocks/dedication/dedication_lib.php:

public function get_students_dedication($students) {
...
  //ORIGINAL: $where = 'courseid = :courseid AND userid = :userid AND timecreated >= :mintime AND timecreated <= :maxtime';
  $where = 'courseid = :courseid AND userid = :userid AND timecreated BETWEEN :mintime AND :maxtime';
...
}

This allows mysql to use an "index condition" for the query.

Comments (1)

  1. Aday Talavera

    Could you show me what database server and Moodle version are you using?

    That query was written some years ago and probably isn’t optimized for new Moodle versions.

  2. Log in to comment