Skip to content

Commit

Permalink
perf: Missing node_parent_position composite index
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Mar 5, 2024
1 parent fd90805 commit 9147b6b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
31 changes: 31 additions & 0 deletions lib/RoadizCoreBundle/migrations/Version20240305143443.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace RZ\Roadiz\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240305143443 extends AbstractMigration
{
public function getDescription(): string
{
return 'Added composite index on nodes parent_node_id and position columns';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE INDEX node_parent_position ON nodes (parent_node_id, position)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX node_parent_position ON nodes');
}
}
3 changes: 2 additions & 1 deletion lib/RoadizCoreBundle/src/Entity/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@
ORM\Index(columns: ["created_at"]),
ORM\Index(columns: ["updated_at"]),
ORM\Index(columns: ["hide_children"]),
ORM\Index(columns: ["home"]),
ORM\Index(columns: ["node_name", "status"]),
ORM\Index(columns: ["visible", "status"]),
ORM\Index(columns: ["visible", "status", "parent_node_id"], name: "node_visible_status_parent"),
ORM\Index(columns: ["status", "parent_node_id"], name: "node_status_parent"),
ORM\Index(columns: ["nodeType_id", "status", "parent_node_id"], name: "node_nodetype_status_parent"),
ORM\Index(columns: ["nodeType_id", "status", "parent_node_id", "position"], name: "node_nodetype_status_parent_position"),
ORM\Index(columns: ["visible", "parent_node_id"], name: "node_visible_parent"),
ORM\Index(columns: ["parent_node_id", "position"], name: "node_parent_position"),
ORM\Index(columns: ["visible", "parent_node_id", "position"], name: "node_visible_parent_position"),
ORM\Index(columns: ["status", "visible", "parent_node_id", "position"], name: "node_status_visible_parent_position"),
ORM\Index(columns: ["home"]),
ORM\HasLifecycleCallbacks,
Gedmo\Loggable(logEntryClass: UserLogEntry::class),
// Need to override repository method to see all nodes
Expand Down

0 comments on commit 9147b6b

Please sign in to comment.