MDL-68647 forum: Add index over posts privatereplyto field
This is to further improve the performance of searching of posts related to the given user. Once both userid and privatereplyto are indexed, the query planner can use the merged index to search for posts records.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="mod/forum/db" VERSION="20191001" COMMENT="XMLDB file for Moodle mod/forum"
|
||||
<XMLDB PATH="mod/forum/db" VERSION="20200508" COMMENT="XMLDB file for Moodle mod/forum"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -99,6 +99,7 @@
|
||||
<INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
|
||||
<INDEX NAME="created" UNIQUE="false" FIELDS="created"/>
|
||||
<INDEX NAME="mailed" UNIQUE="false" FIELDS="mailed"/>
|
||||
<INDEX NAME="privatereplyto" UNIQUE="false" FIELDS="privatereplyto" COMMENT="The field is used in certain queries (such as privacy requests) to search for private replies to the user."/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="forum_queue" COMMENT="For keeping track of posts that will be mailed in digest form">
|
||||
|
||||
@@ -294,5 +294,17 @@ function xmldb_forum_upgrade($oldversion) {
|
||||
upgrade_mod_savepoint(true, 2019111801, 'forum');
|
||||
}
|
||||
|
||||
if ($oldversion < 2019111802) {
|
||||
// Add index privatereplyto (not unique) to the forum_posts table.
|
||||
$table = new xmldb_table('forum_posts');
|
||||
$index = new xmldb_index('privatereplyto', XMLDB_INDEX_NOTUNIQUE, ['privatereplyto']);
|
||||
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
upgrade_mod_savepoint(true, 2019111802, 'forum');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2019111801; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2019111802; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2019111200; // Requires this Moodle version
|
||||
$plugin->component = 'mod_forum'; // Full name of the plugin (used for diagnostics)
|
||||
|
||||
Reference in New Issue
Block a user