From 79a471435bbaa2bbe224a211d431bada13d5f5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0koda?= Date: Mon, 25 Jun 2012 09:31:50 +0200 Subject: [PATCH] MDL-33617 add new index to improve perf of enrol related role_assignments --- lib/db/install.xml | 3 ++- lib/db/upgrade.php | 15 +++++++++++++++ version.php | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index 1d88b4d12cc28..22835b232a01b 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1130,7 +1130,8 @@ - + + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index f50ae6b2798ef..1a98860c7fa07 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -899,6 +899,21 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2012062500.02); } + if ($oldversion < 2012062500.04) { + + // Define index component-itemid-userid (not unique) to be added to role_assignments + $table = new xmldb_table('role_assignments'); + $index = new xmldb_index('component-itemid-userid', XMLDB_INDEX_NOTUNIQUE, array('component', 'itemid', 'userid')); + + // Conditionally launch add index component-itemid-userid + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Main savepoint reached + upgrade_main_savepoint(true, 2012062500.04); + } + return true; } diff --git a/version.php b/version.php index 0e59d871b3e83..b281bb412c30a 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2012062500.03; // YYYYMMDD = weekly release date of this DEV branch +$version = 2012062500.04; // YYYYMMDD = weekly release date of this DEV branch // RR = release increments - 00 in DEV branches // .XX = incremental changes