]> source.dussan.org Git - nextcloud-server.git/commitdiff
perf: Add partial index on configvalue of preferences table 41927/head
authorJulius Härtl <jus@bitgrid.net>
Thu, 30 Nov 2023 15:30:21 +0000 (16:30 +0100)
committerJulius Härtl <jus@bitgrid.net>
Thu, 30 Nov 2023 19:51:48 +0000 (20:51 +0100)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
core/Application.php
core/Migrations/Version13000Date20170718121200.php

index 2ad8b9f2a301470944a40b0fa995470d90fe23c1..b033ea70871cb78b689cc57e527602fc6a75ae6c 100644 (file)
@@ -44,6 +44,7 @@ use OC\Authentication\Listeners\UserDeletedWebAuthnCleanupListener;
 use OC\Authentication\Notifications\Notifier as AuthenticationNotifier;
 use OC\Core\Listener\BeforeTemplateRenderedListener;
 use OC\Core\Notification\CoreNotifier;
+use OC\SystemConfig;
 use OC\TagManager;
 use OCP\AppFramework\App;
 use OCP\AppFramework\Http\Events\BeforeLoginTemplateRenderedEvent;
@@ -81,6 +82,7 @@ class Application extends App {
                $notificationManager->registerNotifierService(AuthenticationNotifier::class);
 
                $eventDispatcher->addListener(AddMissingIndicesEvent::class, function (AddMissingIndicesEvent $event) {
+                       $dbType = $this->getContainer()->get(SystemConfig::class)->getSystemValue('dbtype', 'sqlite');
                        $event->addMissingIndex(
                                'share',
                                'share_with_index',
@@ -237,6 +239,15 @@ class Application extends App {
                                ['appid', 'configkey']
                        );
 
+                       if ($dbType !== 'oci') {
+                               $event->addMissingIndex(
+                                       'preferences',
+                                       'preferences_configvalue',
+                                       ['configvalue'],
+                                       ['lengths' => [80]]
+                               );
+                       }
+
                        $event->addMissingIndex(
                                'mounts',
                                'mounts_class_index',
index da83b0732d8a5ece0718e0777e849a7bd4858611..b4968e063972b7cb44ad705f07aca75101e32245 100644 (file)
@@ -31,6 +31,7 @@
  */
 namespace OC\Core\Migrations;
 
+use Doctrine\DBAL\Platforms\OraclePlatform;
 use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
 use OCP\DB\ISchemaWrapper;
 use OCP\DB\Types;
@@ -332,6 +333,9 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
                        ]);
                        $table->setPrimaryKey(['userid', 'appid', 'configkey']);
                        $table->addIndex(['appid', 'configkey'], 'preferences_app_key');
+                       if (!$this->connection->getDatabasePlatform() instanceof OraclePlatform) {
+                               $table->addIndex(['configvalue'], 'preferences_configvalue', [], ['lengths' => [80]]);
+                       }
                }
 
                if (!$schema->hasTable('properties')) {