mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-60583 webservice: Add index to improve token lookup performance
Without this index every webservice call will do a full table scan when it tries to validate a token. On a busy site with many tokens this adds unnecessary load to the database.
This commit is contained in:
parent
c11e2517a7
commit
b6c7a25d60
3 changed files with 17 additions and 2 deletions
|
@ -2486,5 +2486,17 @@ function xmldb_main_upgrade($oldversion) {
|
|||
upgrade_main_savepoint(true, 2020061500.02);
|
||||
}
|
||||
|
||||
if ($oldversion < 2020062600.01) {
|
||||
// Add index to the token field in the external_tokens table.
|
||||
$table = new xmldb_table('external_tokens');
|
||||
$index = new xmldb_index('token', XMLDB_INDEX_NOTUNIQUE, ['token']);
|
||||
|
||||
if (!$dbman->index_exists($table, $index)) {
|
||||
$dbman->add_index($table, $index);
|
||||
}
|
||||
|
||||
upgrade_main_savepoint(true, 2020062600.01);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue