Browse Source
Additional index on oc_preferences to make sure that gettingh values without a user filter is fast
Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/31047/head
Julius Härtl
4 years ago
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
4 changed files with
25 additions and
0 deletions
-
core/Application.php
-
core/Command/Db/AddMissingIndices.php
-
core/Migrations/Version13000Date20170718121200.php
-
lib/private/AllConfig.php
|
|
|
@ -213,6 +213,13 @@ class Application extends App { |
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'direct_edit_timestamp'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($schema->hasTable('preferences')) { |
|
|
|
$table = $schema->getTable('preferences'); |
|
|
|
if (!$table->hasIndex('preferences_app_key')) { |
|
|
|
$subject->addHintForMissingSubject($table->getName(), 'preferences_app_key'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
@ -435,6 +435,19 @@ class AddMissingIndices extends Command { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$output->writeln('<info>Check indices of the oc_preferences table.</info>'); |
|
|
|
if ($schema->hasTable('preferences')) { |
|
|
|
$table = $schema->getTable('preferences'); |
|
|
|
if (!$table->hasIndex('preferences_app_key')) { |
|
|
|
$output->writeln('<info>Adding preferences_app_key index to the oc_preferences table, this can take some time...</info>'); |
|
|
|
|
|
|
|
$table->addIndex(['appid', 'configkey'], 'preferences_app_key'); |
|
|
|
$this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
|
|
$updated = true; |
|
|
|
$output->writeln('<info>oc_properties table updated successfully.</info>'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!$updated) { |
|
|
|
$output->writeln('<info>Done.</info>'); |
|
|
|
} |
|
|
|
|
|
|
|
@ -333,6 +333,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { |
|
|
|
'notnull' => false, |
|
|
|
]); |
|
|
|
$table->setPrimaryKey(['userid', 'appid', 'configkey']); |
|
|
|
$table->addIndex(['appid', 'configkey'], 'preferences_app_key'); |
|
|
|
} |
|
|
|
|
|
|
|
if (!$schema->hasTable('properties')) { |
|
|
|
|
|
|
|
@ -497,6 +497,8 @@ class AllConfig implements \OCP\IConfig { |
|
|
|
$sql .= 'AND `configvalue` = ?'; |
|
|
|
} |
|
|
|
|
|
|
|
$sql .= ' ORDER BY `userid`'; |
|
|
|
|
|
|
|
$result = $this->connection->executeQuery($sql, [$appName, $key, $value]); |
|
|
|
|
|
|
|
$userIDs = []; |
|
|
|
@ -534,6 +536,8 @@ class AllConfig implements \OCP\IConfig { |
|
|
|
$sql .= 'AND LOWER(`configvalue`) = ?'; |
|
|
|
} |
|
|
|
|
|
|
|
$sql .= ' ORDER BY `userid`'; |
|
|
|
|
|
|
|
$result = $this->connection->executeQuery($sql, [$appName, $key, strtolower($value)]); |
|
|
|
|
|
|
|
$userIDs = []; |
|
|
|
|