Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-03-11 18:37:23 +0300
committerMichaIng <micha@dietpi.com>2021-11-27 04:48:43 +0300
commitdcb99c43ed20e4e5d31333dbe79770607860688a (patch)
tree10719f0bda78a24e620b882f5181ad834686c08c /core
parent0b3d763907c47d9d03af8a9f1e043a829110fe7c (diff)
add a prefix index to filecache.path
The reason that `filecache.path` hasn't had an index added is the mysql limitation of ~1kb for indexeded fields, which is to small for the `path`, however mysql supports indexing only the first N bytes of a column instead of the entire column, allowing us to add an index even if the column is to long. Because the index doesn't cover the entire column it can't be used in all situations where a normal index would be used, but it does cover the `path like 'folder/path/%'` queries that are used in various places. Sqlite and Postgresql don't support prefix indexes, but they also don't have the 1kb limit and DBAL handles the differences in index creation. Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'core')
-rw-r--r--core/Application.php4
-rw-r--r--core/Command/Db/AddMissingIndices.php7
-rw-r--r--core/Migrations/Version13000Date20170718121200.php1
3 files changed, 12 insertions, 0 deletions
diff --git a/core/Application.php b/core/Application.php
index f0478173d43..28f2a435981 100644
--- a/core/Application.php
+++ b/core/Application.php
@@ -114,6 +114,10 @@ class Application extends App {
if (!$table->hasIndex('fs_size')) {
$subject->addHintForMissingSubject($table->getName(), 'fs_size');
}
+
+ if (!$table->hasIndex('fs_storage_path_prefix')) {
+ $subject->addHintForMissingSubject($table->getName(), 'fs_storage_path_prefix');
+ }
}
if ($schema->hasTable('twofactor_providers')) {
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php
index 2e6b3dc9aeb..4a079c945c7 100644
--- a/core/Command/Db/AddMissingIndices.php
+++ b/core/Command/Db/AddMissingIndices.php
@@ -144,6 +144,13 @@ class AddMissingIndices extends Command {
$updated = true;
$output->writeln('<info>Filecache table updated successfully.</info>');
}
+ if (!$table->hasIndex('fs_storage_path_prefix')) {
+ $output->writeln('<info>Adding additional path index to the filecache table, this can take some time...</info>');
+ $table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]);
+ $this->connection->migrateToSchema($schema->getWrappedSchema());
+ $updated = true;
+ $output->writeln('<info>Filecache table updated successfully.</info>');
+ }
}
$output->writeln('<info>Check indices of the twofactor_providers table.</info>');
diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php
index 7b959c6073c..b1a2eb6b2a6 100644
--- a/core/Migrations/Version13000Date20170718121200.php
+++ b/core/Migrations/Version13000Date20170718121200.php
@@ -263,6 +263,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
$table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size');
$table->addIndex(['mtime'], 'fs_mtime');
$table->addIndex(['size'], 'fs_size');
+ $table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]);
}
if (!$schema->hasTable('group_user')) {