Skip to content

Commit 476a41b

Browse files
committed
Additional index on oc_preferences to make sure that gettingh values without a user filter is fast
Signed-off-by: Julius Härtl <[email protected]>
1 parent 26df2c5 commit 476a41b

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

core/Application.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ function (GenericEvent $event) use ($container) {
206206
$subject->addHintForMissingSubject($table->getName(), 'job_lastcheck_reserved');
207207
}
208208
}
209+
210+
if ($schema->hasTable('preferences')) {
211+
$table = $schema->getTable('preferences');
212+
if (!$table->hasIndex('preferences_app_key')) {
213+
$subject->addHintForMissingSubject($table->getName(), 'preferences_app_key');
214+
}
215+
}
209216
}
210217
);
211218

core/Command/Db/AddMissingIndices.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,19 @@ private function addCoreIndexes(OutputInterface $output) {
352352
}
353353
}
354354

355+
$output->writeln('<info>Check indices of the oc_preferences table.</info>');
356+
if ($schema->hasTable('preferences')) {
357+
$table = $schema->getTable('preferences');
358+
if (!$table->hasIndex('preferences_app_key')) {
359+
$output->writeln('<info>Adding preferences_app_key index to the oc_preferences table, this can take some time...</info>');
360+
361+
$table->addIndex(['appid', 'configkey'], 'preferences_app_key');
362+
$this->connection->migrateToSchema($schema->getWrappedSchema());
363+
$updated = true;
364+
$output->writeln('<info>oc_properties table updated successfully.</info>');
365+
}
366+
}
367+
355368
if (!$updated) {
356369
$output->writeln('<info>Done.</info>');
357370
}

core/Migrations/Version13000Date20170718121200.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
333333
'notnull' => false,
334334
]);
335335
$table->setPrimaryKey(['userid', 'appid', 'configkey']);
336+
$table->addIndex(['appid', 'configkey'], 'preferences_app_key');
336337
}
337338

338339
if (!$schema->hasTable('properties')) {

0 commit comments

Comments
 (0)