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

Improve performance of log table

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.5.3, 1.8.3, 1.9, 2.5
    • Fix Version/s: None
    • Component/s: Logging, Performance
    • Labels:
    • Database:
      Any, MySQL
    • Affected Branches:
      MOODLE_15_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_25_STABLE
    • Epic Link:

      Description

      There is somewhat of a performance bug in the way logs/activity reports are handled.

      Activity reports are of course generally slow, and tend to run some very SQL selects. While these are selects are happening, of course no inserts can occur. This blocks essentially all traffic on the site (since almost any page view/action includes a log write).

      This directly relates to the count of log rows you have. In our case we pruned it as much as we could, and were left with 10M+ entries (we have to keep at least 2 semesters, worth of logs), so each select may take 5-15s, which really cripples the site.

      The fix that we implemented is to have 2 tables. One,'log', and one 'log_insert'. We modified the add_to_log in datalib.php to write to 'log_insert' instead of 'log'. Every cron cycle a piece of code run that moves log entries from 'log_insert' to 'log'.

      Martin D. mentioned that logs were one of the things he isn't very happy with the general implementation of, so maybe there needs to be a bigger discussion of it.

      Ill post our patch code when I get back to the states, but it's pretty basic.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              moodle.com moodle.com
              Reporter:
              emerrill Eric Merrill
              Participants:
              Component watchers:
              Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Matteo Scaramuccia, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              25 Vote for this issue
              Watchers:
              18 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: