Skip to content

Commit

Permalink
Merge pull request #30435 from nextcloud/backport/30392/stable21
Browse files Browse the repository at this point in the history
[stable21] Add missing index for propertypath only queries of DAV properties
  • Loading branch information
MichaIng authored Dec 31, 2021
2 parents 072ba3b + 30eb302 commit 1fcfda2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,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');
}
}
}
);
Expand Down
13 changes: 13 additions & 0 deletions core/Command/Db/AddMissingIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,24 @@ private function addCoreIndexes(OutputInterface $output) {
$output->writeln('<info>Check indices of the oc_properties table.</info>');
if ($schema->hasTable('properties')) {
$table = $schema->getTable('properties');
$propertiesUpdated = false;

if (!$table->hasIndex('properties_path_index')) {
$output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>');

$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$propertiesUpdated = true;
}
if (!$table->hasIndex('properties_pathonly_index')) {
$output->writeln('<info>Adding properties_pathonly_index index to the oc_properties table, this can take some time...</info>');

$table->addIndex(['propertypath'], 'properties_pathonly_index');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$propertiesUpdated = true;
}

if ($propertiesUpdated) {
$updated = true;
$output->writeln('<info>oc_properties table updated successfully.</info>');
}
Expand Down
1 change: 1 addition & 0 deletions core/Migrations/Version13000Date20170718121200.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,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')) {
Expand Down

0 comments on commit 1fcfda2

Please sign in to comment.