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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.2, 3.5.5, 3.6.3
    • Fix Version/s: 3.5.6, 3.6.4
    • Component/s: Questions
    • Labels:

      Description

      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:

       

        Attachments

          Activity

            People

            Assignee:
            dvdcastro David Castro
            Reporter:
            dvdcastro David Castro
            Peer reviewer:
            Mark Nelson
            Integrator:
            Jun Pataleta
            Tester:
            CiBoT
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              13/May/19

                Time Tracking

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