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

Epic: Stop repeating db queries

    XMLWordPrintable

    Details

    • Type: Epic
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.7.3, 2.8, 2.9
    • Fix Version/s: None
    • Component/s: General, Performance
    • Labels:

      Description

      We all know that moodle sends lots of db reads to the db server but while working on MDL-38128 (trying to reduce the number of db reads) I've realized that in some cases this goes too far, for example a mod_assign grading page sends 433 db reads and it is not in a specially big course:

      • About 16 users
      • 8 groups
      • Assignment with team submissions and a few submissions

      265 of these 433 are repeated db reads, and this is not an isolated case, I've tried different mod_assign activities combinations and the numbers are always high, I've also been browsing through a few pages and sometimes we just have 1-5 repeated db reads, which is "more or less" acceptable knowing that most of our pages have more than 70-80 db reads and moodle is a monster, but there are many cases (not only in mod_assign, this is all around moodle) where we could save a big big % of db queries caching results. I know though that sometimes we should repeat the same db query because we have to, but when we repeat that big % of queries is because we are doing something wrong and we should prevent it.

      Attaching a patch to show the number of repeated db reads in case I am missing something and I am wrong, but seems that we have a lot of margin to improve performance even though these queries are cached in the db engine, we are still connecting to the db server.

      The patch outputs a debugging() message for each repeated query, I know we can not integrate this, it is there just to scare you but would be important to show the number of repeated db reads on the footer so we know where and what we can improve

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                5 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated: