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

Optimise $DB->replace_all_text()

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Use the replace tool to validate that the replace still works after applying the patch:

      1. Add some text to a label in a course. e.g. 'http://linkedin.com'
      2. Use the /tool/replace/ to search for 'http://' and replace it with 'https://'
      3. Check that the label in the course now contains 'https://linkedin.com'

      It's worth noting that unit tests already cover the replace_all_test() function well.

       

      It would also be good to do a test with all dbs that support replace_all_text() with a larger dataset. Possibly by doing an http -> https migration testing that performance is improved after this patch is applied. This works really well on postgres but have not tested mysql or MS Sql.

      Show
      Use the replace tool to validate that the replace still works after applying the patch: Add some text to a label in a course. e.g. ' http://linkedin.com' Use the /tool/replace/ to search for ' http://'  and replace it with ' https://' Check that the label in the course now contains ' https://linkedin.com' It's worth noting that unit tests already cover the replace_all_test() function well.   It would also be good to do a test with all dbs that support replace_all_text() with a larger dataset. Possibly by doing an http -> https migration testing that performance is improved after this patch is applied. This works really well on postgres but have not tested mysql or MS Sql.
    • Affected Branches:
      MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull Master Branch:
      MDL-60976-master

      Description

      On Postgres the $DB->replace_all_text() function is very inefficient as it updates every tuple even if the REPLACE doesn't actually change anything. This is slow and results in big spikes in DB disk usage when using tool_replace.

      The attached patch only updates fields if they match the search pattern.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              matt.clarkson Matt Clarkson
              Reporter:
              matt.clarkson Matt Clarkson
              Peer reviewer:
              Dan Marsden
              Integrator:
              Damyon Wiese
              Tester:
              Jake Dallimore
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/Jan/18