diff options
author | provokateurin <kate@provokateurin.de> | 2024-08-19 14:41:56 +0200 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2024-08-19 15:00:38 +0200 |
commit | 6539e32d9d4fd28eb87fc5d8f0fa61daab153ee2 (patch) | |
tree | 63b2344d68118ce0aae13e98eb2c08e7389a8107 /core | |
parent | 551ff4955e5f5fc8ffe5427d5facef5447f7fc1b (diff) | |
download | nextcloud-server-perf/core/jobs-index.tar.gz nextcloud-server-perf/core/jobs-index.zip |
perf(core): Add index for jobs last_checked, reserved_at, time_sensitiveperf/core/jobs-index
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'core')
-rw-r--r-- | core/Application.php | 4 | ||||
-rw-r--r-- | core/Migrations/Version31000Date20240819122840.php | 45 |
2 files changed, 47 insertions, 2 deletions
diff --git a/core/Application.php b/core/Application.php index d2bcb18bafb..770fdfb532d 100644 --- a/core/Application.php +++ b/core/Application.php @@ -191,8 +191,8 @@ class Application extends App { $event->addMissingIndex( 'jobs', - 'job_lastcheck_reserved', - ['last_checked', 'reserved_at'] + 'job_last_reserved_sensitive', + ['last_checked', 'reserved_at', 'time_sensitive'] ); $event->addMissingIndex( diff --git a/core/Migrations/Version31000Date20240819122840.php b/core/Migrations/Version31000Date20240819122840.php new file mode 100644 index 00000000000..7664c2a35ac --- /dev/null +++ b/core/Migrations/Version31000Date20240819122840.php @@ -0,0 +1,45 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Core\Migrations; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version31000Date20240819122840 extends SimpleMigrationStep { + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->getTable('jobs'); + + # Remove previous indices + if ($table->hasIndex('job_lastcheck_reserved')) { + $table->dropIndex('job_lastcheck_reserved'); + } + if ($table->hasIndex('jobs_time_sensitive')) { + $table->dropIndex('jobs_time_sensitive'); + } + + # Add updated index + if (!$table->hasIndex('job_last_reserved_sensitive')) { + $table->addIndex(['last_checked', 'reserved_at', 'time_sensitive'], 'job_last_reserved_sensitive'); + } + + return $schema; + } +} |