diff options
author | Joas Schilling <coding@schilljs.com> | 2021-12-02 01:57:40 +0300 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-12-10 10:43:09 +0300 |
commit | 0cd2f885eb6793afedf2c979900fe0d7fc3dd45e (patch) | |
tree | 7e190e32e03934dfa802b5a9bbd0dfa0ca95795d /core | |
parent | 86f2f81740e4acd7ba25661b2963a58f4967b43f (diff) |
Add an index for selecting the next job
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/Application.php | 7 | ||||
-rw-r--r-- | core/Command/Db/AddMissingIndices.php | 13 | ||||
-rw-r--r-- | core/Migrations/Version13000Date20170718121200.php | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/core/Application.php b/core/Application.php index f0478173d43..460a645f10c 100644 --- a/core/Application.php +++ b/core/Application.php @@ -187,6 +187,13 @@ class Application extends App { $subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); } } + + if ($schema->hasTable('jobs')) { + $table = $schema->getTable('jobs'); + if (!$table->hasIndex('job_lastcheck_reserved')) { + $subject->addHintForMissingSubject($table->getName(), 'job_lastcheck_reserved'); + } + } } ); diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 2e6b3dc9aeb..79269a01f53 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -311,6 +311,19 @@ class AddMissingIndices extends Command { } } + $output->writeln('<info>Check indices of the oc_jobs table.</info>'); + if ($schema->hasTable('jobs')) { + $table = $schema->getTable('jobs'); + if (!$table->hasIndex('job_lastcheck_reserved')) { + $output->writeln('<info>Adding job_lastcheck_reserved index to the oc_jobs table, this can take some time...</info>'); + + $table->addIndex(['last_checked', 'reserved_at'], 'job_lastcheck_reserved'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('<info>oc_properties table updated successfully.</info>'); + } + } + if (!$updated) { $output->writeln('<info>Done.</info>'); } diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index 7b959c6073c..a6ff1cbfa94 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -520,6 +520,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { ]); $table->setPrimaryKey(['id']); $table->addIndex(['class'], 'job_class_index'); + $table->addIndex(['last_checked', 'reserved_at'], 'job_lastcheck_reserved'); } if (!$schema->hasTable('users')) { |