Permalink
Browse files

MDL-43797 lib/db/upgrade.php: Optimise sql for my_pages deletion

Change-Id: I329ef400cf2e3da80450460901e28061b42b0fd4
  • Loading branch information...
1 parent 0be6396 commit 64e6f2348e9c57f583ebe9d9414d2fcd104e1f55 @DavidCurry DavidCurry committed Jan 27, 2014
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/db/upgrade.php
View
@@ -2331,12 +2331,13 @@ function xmldb_main_upgrade($oldversion) {
if ($oldversion < 2013051404.04) {
// Remove deleted users home pages.
- $active = $DB->get_fieldset_select('user', 'id', 'deleted = ?', array(0));
- list($insql, $params) = $DB->get_in_or_equal($active, SQL_PARAMS_QM, 'param', false);
- $sql = 'DELETE FROM {my_pages}
- WHERE userid ' . $insql;
-
- $DB->execute($sql, $params);
+ $sql = "DELETE FROM {my_pages}
+ WHERE EXISTS (SELECT {user}.id
+ FROM {user}
+ WHERE {user}.id = {my_pages}.userid
+ AND {user}.deleted = 1)
+ AND {my_pages}.private = 1";
+ $DB->execute($sql);
// Reached main savepoint.
upgrade_main_savepoint(true, 2013051404.04);

0 comments on commit 64e6f23

Please sign in to comment.