]> source.dussan.org Git - nextcloud-server.git/commitdiff
Additional index on oc_preferences to make sure that gettingh values without a user... 31047/head
authorJulius Härtl <jus@bitgrid.net>
Mon, 7 Feb 2022 08:55:39 +0000 (09:55 +0100)
committerJulius Härtl <jus@bitgrid.net>
Tue, 19 Apr 2022 10:37:36 +0000 (12:37 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
core/Application.php
core/Command/Db/AddMissingIndices.php
core/Migrations/Version13000Date20170718121200.php
lib/private/AllConfig.php

index 545588ab208a7c3b551d11af8059d37a006d2b0e..f5c39a20013f71d4ff295f91fcbc9b33a3ad38a9 100644 (file)
@@ -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');
+                                       }
+                               }
                        }
                );
 
index a4379ffacc3bec3800e40b81a7df69d1b28a0d3f..8394e75e845bc343d54b164b98d731a07261cc29 100644 (file)
@@ -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>');
                }
index 02864830b2cdf4825e79709a5d09cb77f377c83b..3e14b4af47adbbe89379f478aa4a7663d4773a55 100644 (file)
@@ -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')) {
index 36eb0bbf6d932b6a1bec3e3fee1e8bca321c46f7..e5a6e6a5acd5969bbc6ae6c773e3c5bba78bee0a 100644 (file)
@@ -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 = [];