Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20] add a prefix index to filecache.path, attempt 2 #29364

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

namespace OC\Core;

use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use OC\Authentication\Events\RemoteWipeFinished;
use OC\Authentication\Events\RemoteWipeStarted;
use OC\Authentication\Listeners\RemoteWipeActivityListener;
Expand Down Expand Up @@ -107,6 +108,10 @@ function (GenericEvent $event) use ($container) {
if (!$table->hasIndex('fs_mtime')) {
$subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
}

if (!$table->hasIndex('fs_storage_path_prefix') && !$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) {
$subject->addHintForMissingSubject($table->getName(), 'fs_storage_path_prefix');
}
}

if ($schema->hasTable('twofactor_providers')) {
Expand Down
8 changes: 8 additions & 0 deletions core/Command/Db/AddMissingIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

namespace OC\Core\Command\Db;

use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use OC\DB\SchemaWrapper;
use OCP\IDBConnection;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -135,6 +136,13 @@ private function addCoreIndexes(OutputInterface $output) {
$updated = true;
$output->writeln('<info>Filecache table updated successfully.</info>');
}
if (!$table->hasIndex('fs_storage_path_prefix') && !$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) {
$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>');
Expand Down
4 changes: 4 additions & 0 deletions core/Migrations/Version13000Date20170718121200.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

namespace OC\Core\Migrations;

use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
Expand Down Expand Up @@ -260,6 +261,9 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
$table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart');
$table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size');
$table->addIndex(['mtime'], 'fs_mtime');
if (!$schema->getDatabasePlatform() instanceof PostgreSQL94Platform) {
$table->addIndex(['storage', 'path'], 'fs_storage_path_prefix', [], ['lengths' => [null, 64]]);
}
}

if (!$schema->hasTable('group_user')) {
Expand Down
12 changes: 12 additions & 0 deletions lib/private/DB/SchemaWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace OC\DB;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Schema;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
Expand Down Expand Up @@ -133,4 +134,15 @@ public function dropTable($tableName) {
public function getTables() {
return $this->schema->getTables();
}

/**
* Gets the DatabasePlatform for the database.
*
* @return AbstractPlatform
*
* @throws Exception
*/
public function getDatabasePlatform() {
return $this->connection->getDatabasePlatform();
}
}
14 changes: 13 additions & 1 deletion lib/public/DB/ISchemaWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

namespace OCP\DB;

use Doctrine\DBAL\Platforms\AbstractPlatform;

/**
* Interface ISchemaWrapper
*
Expand Down Expand Up @@ -82,12 +84,22 @@ public function getTables();
* @since 13.0.0
*/
public function getTableNames();

/**
* Gets all table names
*
* @return array
* @since 13.0.0
*/
public function getTableNamesWithoutPrefix();

/**
* Gets the DatabasePlatform for the database.
*
* @return AbstractPlatform
*
* @throws Exception
* @since 23.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, adding APIs in backports ? 🤔

*/
public function getDatabasePlatform();
}