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

AJAX Chat performs query in loop

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3, 2.4.9, 2.5.5, 2.6.2, 2.7
    • Fix Version/s: 2.5.6, 2.6.3
    • Component/s: Chat, Performance
    • Labels:
    • Testing Instructions:
      Hide

      Please don't forget to test this also in stables. Chat code is tricky and we ned to explicitly verify the change does not break anything there.

      Basically test for regressions - use the same chat to enter from two browsers as two different users and make sure the list of current users updates properly

      Show
      Please don't forget to test this also in stables. Chat code is tricky and we ned to explicitly verify the change does not break anything there. Basically test for regressions - use the same chat to enter from two browsers as two different users and make sure the list of current users updates properly
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull Master Branch:
      wip-MDL-34012-master

      Description

      mod/chat/chat_ajax.php calls chat_get_users() whilst in a for loop of messages. The chat_get_users function is not message specific and returns a distinct query with multiple joins and orders.

      On a busy site (or when running load testing) where you've got potentially tens of messages at a time, this means running the same function multiple times needlessly.
      On one load testing run, I saw 1800 database reads!

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                12/May/14