]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add an index for selecting the next job 30032/head
authorJoas Schilling <coding@schilljs.com>
Wed, 1 Dec 2021 22:57:40 +0000 (23:57 +0100)
committerJoas Schilling <coding@schilljs.com>
Wed, 1 Dec 2021 22:57:40 +0000 (23:57 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
core/Application.php
core/Command/Db/AddMissingIndices.php
core/Migrations/Version13000Date20170718121200.php

index d987f7cfb17b2309a8bc8777ecc704997ad3844f..4e36d59baac420991252f26d1e378739c80c719c 100644 (file)
@@ -196,6 +196,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');
+                                       }
+                               }
                        }
                );
 
index 348b4f94f0d56f568a9aa6b2ddb7dc942a5fbd14..57fa49149f6b29eaadbaa9547ea637e567436043 100644 (file)
@@ -326,6 +326,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>');
                }
index 4fa8fb3d1e960335b2d32d95f0fe86d18872415f..3d97ee1de39c7ebf5f09e551f554c4889fe0a989 100644 (file)
@@ -525,6 +525,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')) {