Permalink
Browse files

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

Change-Id: Ibf8da394e3357fdde351eac49627539eb412e247
  • Loading branch information...
DavidCurry committed Jan 27, 2014
1 parent ade2c99 commit 9eb88a59dde232bda370cf7b4e63ce036b807f93
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/db/upgrade.php
View
@@ -2913,12 +2913,13 @@ function xmldb_main_upgrade($oldversion) {
if ($oldversion < 2013111801.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);
// Main savepoint reached.
upgrade_main_savepoint(true, 2013111801.04);

0 comments on commit 9eb88a5

Please sign in to comment.