Преглед на файлове

Merge pull request #31047 from nextcloud/enh/preferences-index

Additional index on oc_preferences to make queries without a user filter faster
tags/v25.0.0beta1
Julius Härtl преди 2 години
родител
ревизия
f4135c72f5
No account linked to committer's email address
променени са 4 файла, в които са добавени 25 реда и са изтрити 0 реда
  1. 7
    0
      core/Application.php
  2. 13
    0
      core/Command/Db/AddMissingIndices.php
  3. 1
    0
      core/Migrations/Version13000Date20170718121200.php
  4. 4
    0
      lib/private/AllConfig.php

+ 7
- 0
core/Application.php Целия файл

$subject->addHintForMissingSubject($table->getName(), 'direct_edit_timestamp'); $subject->addHintForMissingSubject($table->getName(), 'direct_edit_timestamp');
} }
} }

if ($schema->hasTable('preferences')) {
$table = $schema->getTable('preferences');
if (!$table->hasIndex('preferences_app_key')) {
$subject->addHintForMissingSubject($table->getName(), 'preferences_app_key');
}
}
} }
); );



+ 13
- 0
core/Command/Db/AddMissingIndices.php Целия файл

} }
} }


$output->writeln('<info>Check indices of the oc_preferences table.</info>');
if ($schema->hasTable('preferences')) {
$table = $schema->getTable('preferences');
if (!$table->hasIndex('preferences_app_key')) {
$output->writeln('<info>Adding preferences_app_key index to the oc_preferences table, this can take some time...</info>');

$table->addIndex(['appid', 'configkey'], 'preferences_app_key');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$updated = true;
$output->writeln('<info>oc_properties table updated successfully.</info>');
}
}

if (!$updated) { if (!$updated) {
$output->writeln('<info>Done.</info>'); $output->writeln('<info>Done.</info>');
} }

+ 1
- 0
core/Migrations/Version13000Date20170718121200.php Целия файл

'notnull' => false, 'notnull' => false,
]); ]);
$table->setPrimaryKey(['userid', 'appid', 'configkey']); $table->setPrimaryKey(['userid', 'appid', 'configkey']);
$table->addIndex(['appid', 'configkey'], 'preferences_app_key');
} }


if (!$schema->hasTable('properties')) { if (!$schema->hasTable('properties')) {

+ 4
- 0
lib/private/AllConfig.php Целия файл

$sql .= 'AND `configvalue` = ?'; $sql .= 'AND `configvalue` = ?';
} }


$sql .= ' ORDER BY `userid`';

$result = $this->connection->executeQuery($sql, [$appName, $key, $value]); $result = $this->connection->executeQuery($sql, [$appName, $key, $value]);


$userIDs = []; $userIDs = [];
$sql .= 'AND LOWER(`configvalue`) = ?'; $sql .= 'AND LOWER(`configvalue`) = ?';
} }


$sql .= ' ORDER BY `userid`';

$result = $this->connection->executeQuery($sql, [$appName, $key, strtolower($value)]); $result = $this->connection->executeQuery($sql, [$appName, $key, strtolower($value)]);


$userIDs = []; $userIDs = [];

Loading…
Отказ
Запис