Permalink
Browse files

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

Change-Id: Idf300ab07afda3bcefea80e617549f40c710e529
  • Loading branch information...
1 parent a5ab83a commit c8ade8cbdc1496d015e9030c8790c3c249958ade @DavidCurry DavidCurry committed Jan 27, 2014
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/db/upgrade.php
View
13 lib/db/upgrade.php
@@ -2929,12 +2929,13 @@ function xmldb_main_upgrade($oldversion) {
if ($oldversion < 2014012300.01) {
// 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, 2014012300.01);

0 comments on commit c8ade8c

Please sign in to comment.