From 7fbd93b2ad66a1ca83ef2a2778128bf2cda06caf Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Mon, 7 Feb 2022 09:55:39 +0100 Subject: Additional index on oc_preferences to make sure that gettingh values without a user filter is fast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- core/Application.php | 7 +++++++ core/Command/Db/AddMissingIndices.php | 13 +++++++++++++ core/Migrations/Version13000Date20170718121200.php | 1 + 3 files changed, 21 insertions(+) (limited to 'core') diff --git a/core/Application.php b/core/Application.php index 545588ab208..f5c39a20013 100644 --- a/core/Application.php +++ b/core/Application.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'); + } + } } ); diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index a4379ffacc3..8394e75e845 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -435,6 +435,19 @@ class AddMissingIndices extends Command { } } + $output->writeln('Check indices of the oc_preferences table.'); + if ($schema->hasTable('preferences')) { + $table = $schema->getTable('preferences'); + if (!$table->hasIndex('preferences_app_key')) { + $output->writeln('Adding preferences_app_key index to the oc_preferences table, this can take some time...'); + + $table->addIndex(['appid', 'configkey'], 'preferences_app_key'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('oc_properties table updated successfully.'); + } + } + if (!$updated) { $output->writeln('Done.'); } diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index 02864830b2c..3e14b4af47a 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -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')) { -- cgit v1.2.3