From 91d3e48ab30c7b195169edb1d07957c6b26f917f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 19 Jul 2018 17:30:41 +0200 Subject: [PATCH] Add filecache index on mtime Gives searching by mtime and "recent" a proper index to use Signed-off-by: Robin Appelman --- core/Application.php | 8 ++++++++ core/Command/Db/AddMissingIndices.php | 11 +++++++++++ core/Migrations/Version13000Date20170718121200.php | 1 + 3 files changed, 20 insertions(+) diff --git a/core/Application.php b/core/Application.php index 400d86f599..336538187d 100644 --- a/core/Application.php +++ b/core/Application.php @@ -71,6 +71,14 @@ class Application extends App { $subject->addHintForMissingSubject($table->getName(), 'parent_index'); } } + + if ($schema->hasTable('filecache')) { + $table = $schema->getTable('filecache'); + + if (!$table->hasIndex('fs_mtime')) { + $subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); + } + } } ); } diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index b30fa43ab3..5d78d360b4 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -100,6 +100,17 @@ class AddMissingIndices extends Command { } } + if ($schema->hasTable('filecache')) { + $table = $schema->getTable('filecache'); + if (!$table->hasIndex('fs_mtime')) { + $output->writeln('Adding additional mtime index to the filecache table, this can take some time...'); + $table->addIndex(['mtime'], 'fs_mtime'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('Filecache table updated successfully.'); + } + } + if (!$updated) { $output->writeln('Done.'); } diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index 05623e435c..29687b8683 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -215,6 +215,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { $table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype'); $table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart'); $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size'); + $table->addIndex(['mtime'], 'fs_mtime'); } if (!$schema->hasTable('group_user')) {