From 3cf98b75e2802149c39c66bff455c7bd8246fcd2 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 23 Dec 2021 11:34:51 +0100 Subject: [PATCH] Add missing index for propertypath only queries against properties Signed-off-by: Christoph Wurst --- core/Application.php | 3 +++ core/Command/Db/AddMissingIndices.php | 13 +++++++++++++ core/Migrations/Version13000Date20170718121200.php | 1 + 3 files changed, 17 insertions(+) diff --git a/core/Application.php b/core/Application.php index 4e36d59baac42..0f363f8c699ce 100644 --- a/core/Application.php +++ b/core/Application.php @@ -195,6 +195,9 @@ function (GenericEvent $event) use ($container) { if (!$table->hasIndex('properties_path_index')) { $subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); } + if (!$table->hasIndex('properties_pathonly_index')) { + $subject->addHintForMissingSubject($table->getName(), 'properties_pathonly_index'); + } } if ($schema->hasTable('jobs')) { diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 57fa49149f6b2..4c86a8705db42 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -316,11 +316,24 @@ private function addCoreIndexes(OutputInterface $output) { $output->writeln('Check indices of the oc_properties table.'); if ($schema->hasTable('properties')) { $table = $schema->getTable('properties'); + $propertiesUpdated = false; + if (!$table->hasIndex('properties_path_index')) { $output->writeln('Adding properties_path_index index to the oc_properties table, this can take some time...'); $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); $this->connection->migrateToSchema($schema->getWrappedSchema()); + $propertiesUpdated = true; + } + if (!$table->hasIndex('properties_pathonly_index')) { + $output->writeln('Adding properties_pathonly_index index to the oc_properties table, this can take some time...'); + + $table->addIndex(['propertypath'], 'properties_pathonly_index'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $propertiesUpdated = true; + } + + if ($propertiesUpdated) { $updated = true; $output->writeln('oc_properties table updated successfully.'); } diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index 3d97ee1de39c7..02864830b2cdf 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -363,6 +363,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op $table->setPrimaryKey(['id']); $table->addIndex(['userid'], 'property_index'); $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); + $table->addIndex(['propertypath'], 'properties_pathonly_index'); } else { $table = $schema->getTable('properties'); if ($table->hasColumn('propertytype')) {