mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
perf(sharing): Add a better index to select shares as they always have type+with
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
17b8f15ea8
commit
792560b02b
3 changed files with 69 additions and 3 deletions
|
|
@ -79,10 +79,18 @@ class Application extends App {
|
|||
$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',
|
||||
|
|
|
|||
|
|
@ -475,7 +475,9 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
|
|||
$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');
|
||||
|
|
|
|||
56
core/Migrations/Version29000Date20240209123412.php
Normal file
56
core/Migrations/Version29000Date20240209123412.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2024 Your name <your@email.com>
|
||||
*
|
||||
* @author Your name <your@email.com>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue