Skip to content

Commit

Permalink
Additional index on oc_preferences to make sure that gettingh values …
Browse files Browse the repository at this point in the history
…without a user filter is fast

Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl committed Feb 7, 2022
1 parent 26df2c5 commit 476a41b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ function (GenericEvent $event) use ($container) {
$subject->addHintForMissingSubject($table->getName(), 'job_lastcheck_reserved');
}
}

if ($schema->hasTable('preferences')) {
$table = $schema->getTable('preferences');
if (!$table->hasIndex('preferences_app_key')) {
$subject->addHintForMissingSubject($table->getName(), 'preferences_app_key');
}
}
}
);

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 @@ -352,6 +352,19 @@ private function addCoreIndexes(OutputInterface $output) {
}
}

$output->writeln('<info>Check indices of the oc_preferences table.</info>');
if ($schema->hasTable('preferences')) {
$table = $schema->getTable('preferences');
if (!$table->hasIndex('preferences_app_key')) {
$output->writeln('<info>Adding preferences_app_key index to the oc_preferences table, this can take some time...</info>');

$table->addIndex(['appid', 'configkey'], 'preferences_app_key');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$updated = true;
$output->writeln('<info>oc_properties table updated successfully.</info>');
}
}

if (!$updated) {
$output->writeln('<info>Done.</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 @@ -333,6 +333,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
'notnull' => false,
]);
$table->setPrimaryKey(['userid', 'appid', 'configkey']);
$table->addIndex(['appid', 'configkey'], 'preferences_app_key');
}

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

0 comments on commit 476a41b

Please sign in to comment.