Skip to content

Commit

Permalink
Merge branch 'MDL-46161_files_reference_index' of git://github.com/da…
Browse files Browse the repository at this point in the history
…vosmith/moodle

Conflicts:
	lib/db/upgrade.php
	version.php
  • Loading branch information
danpoltawski committed Jul 1, 2014
2 parents 2a957cd + 463882d commit 9b19282
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/db/install.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20140324" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20140627" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
Expand Down Expand Up @@ -2358,7 +2358,7 @@
<KEY NAME="repositoryid" TYPE="foreign" FIELDS="repositoryid" REFTABLE="repository_instances" REFFIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="uq_external_file" UNIQUE="true" FIELDS="repositoryid, referencehash" COMMENT="The combination of repositoryid and reference field is supposed to be a unique identification of an external file. Because the reference is a TEXT field, we can't use to compose the index. So we use the referencehash instead and the file API is responsible to keep it up-to-date"/>
<INDEX NAME="uq_external_file" UNIQUE="true" FIELDS="referencehash, repositoryid" COMMENT="The combination of repositoryid and reference field is supposed to be a unique identification of an external file. Because the reference is a TEXT field, we can't use to compose the index. So we use the referencehash instead and the file API is responsible to keep it up-to-date"/>
</INDEXES>
</TABLE>
<TABLE NAME="repository" COMMENT="This table contains one entry for every configured external repository instance.">
Expand Down
19 changes: 19 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3688,5 +3688,24 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2014062600.01);
}

// Switch the order of the fields in the files_reference index, to improve the performance of search_references.
if ($oldversion < 2014070100.00) {
$table = new xmldb_table('files_reference');
$index = new xmldb_index('uq_external_file', XMLDB_INDEX_UNIQUE, array('repositoryid', 'referencehash'));
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
upgrade_main_savepoint(true, 2014070100.00);
}

if ($oldversion < 2014070101.00) {
$table = new xmldb_table('files_reference');
$index = new xmldb_index('uq_external_file', XMLDB_INDEX_UNIQUE, array('referencehash', 'repositoryid'));
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
upgrade_main_savepoint(true, 2014070101.00);
}

return true;
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2014062600.01; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2014070101.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit 9b19282

Please sign in to comment.