Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
perf(sharing): Add a better index to select shares as they always hav…
…e type+with

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Feb 9, 2024
commit 792560b02b0df997513e5d8a1d8bb316355c61fc
12 changes: 10 additions & 2 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,18 @@ public function __construct() {
$notificationManager->registerNotifierService(AuthenticationNotifier::class);

$eventDispatcher->addListener(AddMissingIndicesEvent::class, function (AddMissingIndicesEvent $event) {
/**
* Replaced by the share_type_with index below
* $event->addMissingIndex(
* 'share',
* 'share_with_index',
* ['share_with']
* );
*/
$event->addMissingIndex(
'share',
'share_with_index',
['share_with']
'share_type_with',
['share_type', 'share_with']
);
$event->addMissingIndex(
'share',
Expand Down
4 changes: 3 additions & 1 deletion core/Migrations/Version13000Date20170718121200.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
$table->addIndex(['item_type', 'share_type'], 'item_share_type_index');
$table->addIndex(['file_source'], 'file_source_index');
$table->addIndex(['token'], 'token_index');
$table->addIndex(['share_with'], 'share_with_index');
// Replaced by the share_type_with index below
// $table->addIndex(['share_with'], 'share_with_index');
$table->addIndex(['share_type', 'share_with'], 'share_type_with');
$table->addIndex(['parent'], 'parent_index');
$table->addIndex(['uid_owner'], 'owner_index');
$table->addIndex(['uid_initiator'], 'initiator_index');
Expand Down
56 changes: 56 additions & 0 deletions core/Migrations/Version29000Date20240209123412.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2024 Your name <[email protected]>
*
* @author Your name <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OC\Core\Migrations;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version29000Date20240209123412 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('share');
if ($table->hasIndex('share_with_index')) {
$table->dropIndex('share_with_index');
return $schema;
}
return null;
}

}