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

Add component to tag_instance sql in question backup definition so taggeditem index is used

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.5.6, 3.6.4
    • 3.5.2, 3.5.5, 3.6.3
    • Questions

      The class \backup_questions_structure_step found in backup/moodle2/backup_stepslib.php has a DB query for getting the tag instances associated with a question:

               $tag->set_source_sql("SELECT t.id, ti.contextid, t.name, t.rawname
                                    FROM {tag} t
                                    JOIN {tag_instance} ti ON ti.tagid = t.id
                                    WHERE ti.itemid = ?
                                    AND ti.itemtype = 'question'", array(backup::VAR_PARENTID));
      

      This query seems to be costly because it's not using a better index. You can test when running EXPLAIN:

       

      After some digging, the taglookup index is used if the component is specified:

       

            dvdcastro David Castro
            dvdcastro David Castro
            Mark Nelson Mark Nelson
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h

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