Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-65230

Recordset interface to get analysables

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Done
    • 3.7
    • None
    • Analytics, Performance
    • None
    • MOODLE_37_STABLE

    Description

      At the moment the get_analysables interface returns an array. The recommended approach is to return the analysable ids in the site so we don't reach PHP's memory limit. This requires each analysable element to separately load their data from db. The current approach is O(n), where n is the number of analysable elements in a site. This is not nice because n can be very large and this query runs every time the analytics scheduled task runs. I propose a new O(1) interface that returns a \moodle_recordset or a \recordset_walk, and that its responsibilities include the job get_sorted_analysables is currently doing. This is done via the left join with analytics_used_analysables.

              $select = 'c.*, ' . context_helper::get_preload_record_columns_sql('ctx');
              $sql = "SELECT $select
                        FROM {course} c
                        JOIN {context} ctx ON (ctx.contextlevel = :contextlevel AND ctx.instanceid = c.id)
                   LEFT JOIN {analytics_used_analysables} aua ON aua.analysableid = c.id
                       WHERE aua.modelid = :modelid AND aua.action = :action
                    ORDER BY aua.timeanalyzed DESC, c.sortorder ASC";
              $params = ['contextlevel' => CONTEXT_COURSE, 'modelid' => $this->get_modelid(), 'action' => $action];
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dmonllao David Monllaó
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: