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

rss_get_userid_from_token does not use the existing compound index any more

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 4.0.7, 4.1.2
    • 3.10.10, 3.11.6, 4.0, 4.0.6, 4.1.1
    • Performance, RSS

      Our DBAs have noticed that Moodle has some inefficient queries related to the user_private_key table.

      The specific query they have noticed is:

      SELECT u.id FROM mdl_user u
      JOIN mdl_user_private_key k ON u.id = k.userid
      WHERE u.deleted = 0 AND u.confirmed = 1
      AND u.suspended = 0 AND k.value = 'c70d6d9e51ed81702bdfd73626ded013';
      

      This query seems to be getting called when users access their RSS feeds (this example is from Moodle 3.10):

      in mysqli::query called at /var/www/html/lib/dml/mysqli_native_moodle_database.php (1272)
         in mysqli_native_moodle_database::get_records_sql called at /var/www/html/lib/dml/moodle_database.php (1671)
            in moodle_database::get_record_sql called at /var/www/html/lib/dml/moodle_database.php (1744)
               in moodle_database::get_field_sql called at /var/www/html/lib/rsslib.php (420)
                  in rss_get_userid_from_token called at /var/www/html/rss/file.php (111)
      

      I have attached their analysis of this query.

      Their recommendation is that and index is added for the value column to the table.

      This suggestion would likely also increase performance of other queries, such as the one used in the creation of tokens

            mudrd8mz David Mudrák (@mudrd8mz)
            nmagill Neill Magill
            Tim Hunt Tim Hunt
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 5 minutes
                1h 5m

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