Skip to content

Commit ed84f07

Browse files
Add missing index for propertypath only queries against properties
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
1 parent 29dffd7 commit ed84f07

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

core/Application.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ function (GenericEvent $event) use ($container) {
195195
if (!$table->hasIndex('properties_path_index')) {
196196
$subject->addHintForMissingSubject($table->getName(), 'properties_path_index');
197197
}
198+
if (!$table->hasIndex('properties_pathonly_index')) {
199+
$subject->addHintForMissingSubject($table->getName(), 'properties_pathonly_index');
200+
}
198201
}
199202

200203
if ($schema->hasTable('jobs')) {

core/Command/Db/AddMissingIndices.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,24 @@ private function addCoreIndexes(OutputInterface $output) {
316316
$output->writeln('<info>Check indices of the oc_properties table.</info>');
317317
if ($schema->hasTable('properties')) {
318318
$table = $schema->getTable('properties');
319+
$propertiesUpdated = false;
320+
319321
if (!$table->hasIndex('properties_path_index')) {
320322
$output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>');
321323

322324
$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
323325
$this->connection->migrateToSchema($schema->getWrappedSchema());
326+
$propertiesUpdated = true;
327+
}
328+
if (!$table->hasIndex('properties_pathonly_index')) {
329+
$output->writeln('<info>Adding properties_pathonly_index index to the oc_properties table, this can take some time...</info>');
330+
331+
$table->addIndex(['propertypath'], 'properties_pathonly_index');
332+
$this->connection->migrateToSchema($schema->getWrappedSchema());
333+
$propertiesUpdated = true;
334+
}
335+
336+
if ($propertiesUpdated) {
324337
$updated = true;
325338
$output->writeln('<info>oc_properties table updated successfully.</info>');
326339
}

core/Migrations/Version13000Date20170718121200.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
363363
$table->setPrimaryKey(['id']);
364364
$table->addIndex(['userid'], 'property_index');
365365
$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
366+
$table->addIndex(['propertypath'], 'properties_pathonly_index');
366367
} else {
367368
$table = $schema->getTable('properties');
368369
if ($table->hasColumn('propertytype')) {

0 commit comments

Comments
 (0)