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

Improve performance of log table


    • 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: BACKEND
    • Component/s: Logging, Performance
    • Labels:
    • Database:
      Any, MySQL
    • Affected Branches:
    • Epic Link:


      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.

        Gliffy Diagrams


            Issue Links



                • Votes:
                  25 Vote for this issue
                  18 Start watching this issue


                  • Created: