Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-5546

Journal is slow because of db querys

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • 2.6.7, 2.7.4, 2.8.2
    • Module: Journal
    • None
    • Oracle
    • Hide

      Replace the foreach code from the description below for that:

          $canadd = get_users_by_capability($context, 'mod/journal:addentries');
          $entriesmanager = get_users_by_capability($context, 'mod/journal:manageentries');
       
          // remove unenrolled participants
          foreach ($journals as $userid => $notused) {
       
              if (!isset($entriesmanager[$userid]) && !isset($canadd[$userid])) {
                  unset($journals[$userid]);
              }
          }
      

      Show
      Replace the foreach code from the description below for that: $canadd = get_users_by_capability($context, 'mod/journal:addentries'); $entriesmanager = get_users_by_capability($context, 'mod/journal:manageentries');   // remove unenrolled participants foreach ($journals as $userid => $notused) {   if (!isset($entriesmanager[$userid]) && !isset($canadd[$userid])) { unset($journals[$userid]); } }
    • MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE

      Hi,
      When showing Journal as a teacher it counts the number of entries. To calculate that it counts all the entries and removes the ones from unenrolled users. This causes that the number of querys increase 5 querys per entry.

      We are using Oracle as DB and Moodle 2.6.7. We've realised that oracle can be the point but not the Moodle version.

      Testing that it ha for view.php:
      88 reads for a brand new journal activity created.
      850 for a journal with about 150 users and entries.

      All this is caused by the following code inside journal_count_entries function:

      foreach ($journals as $key => $user) {
       
              $canadd = has_capability('mod/journal:addentries', $context, $user);
              $entriesmanager = has_capability('mod/journal:manageentries', $context, $user);
       
              if (!$entriesmanager && !$canadd) {
                  unset($journals[$key]);
              }
          }
      

      I think this have to be replaced by getting all users enroled and matching both $journals and $userenroled arrays.

            dmonllao David Monllaó
            pferre22 Pau Ferrer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.