Skip to content
Merged
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
perf: Add partial index on configvalue of preferences table
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Nov 30, 2023
commit 0ccf84bb3174a0dba47938888d104db96dcacb1b
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