Skip to content

Commit

Permalink
perf: Add partial index on configvalue of preferences table
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl committed Jan 9, 2024
1 parent e087722 commit 225a430
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use OC\Authentication\Notifications\Notifier as AuthenticationNotifier;
use OC\Core\Listener\BeforeTemplateRenderedListener;
use OC\Core\Notification\CoreNotifier;
use OC\SystemConfig;
use OC\TagManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Http\Events\BeforeLoginTemplateRenderedEvent;
Expand Down Expand Up @@ -81,6 +82,7 @@ public function __construct() {
$notificationManager->registerNotifierService(AuthenticationNotifier::class);

$eventDispatcher->addListener(AddMissingIndicesEvent::class, function (AddMissingIndicesEvent $event) {
$dbType = $this->getContainer()->get(SystemConfig::class)->getSystemValue('dbtype', 'sqlite');
$event->addMissingIndex(
'share',
'share_with_index',
Expand Down Expand Up @@ -237,6 +239,15 @@ public function __construct() {
['appid', 'configkey']
);

if ($dbType !== 'oci') {
$event->addMissingIndex(
'preferences',
'preferences_configvalue',
['configvalue'],
['lengths' => [80]]
);
}

$event->addMissingIndex(
'mounts',
'mounts_class_index',
Expand Down
4 changes: 4 additions & 0 deletions core/Migrations/Version13000Date20170718121200.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/
namespace OC\Core\Migrations;

use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
Expand Down Expand Up @@ -332,6 +333,9 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
]);
$table->setPrimaryKey(['userid', 'appid', 'configkey']);
$table->addIndex(['appid', 'configkey'], 'preferences_app_key');
if (!$this->connection->getDatabasePlatform() instanceof OraclePlatform) {
$table->addIndex(['configvalue'], 'preferences_configvalue', [], ['lengths' => [80]]);
}
}

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

0 comments on commit 225a430

Please sign in to comment.