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

Improve performance of log table

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Won't Fix
    • Icon: Major Major
    • None
    • 1.5.3, 1.8.3, 1.9, 2.5
    • Logging, Performance
    • Any, MySQL
    • MOODLE_15_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_25_STABLE

      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.

            moodle.com Moodle HQ
            emerrill Eric Merrill
            Votes:
            25 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved:

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