From d1083e97cbea3de2db6766bf1d6f73c20dd6c410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Nov 2018 21:53:28 +0100 Subject: [PATCH] adding indexes --- CHANGELOG.md | 5 ++++ Entity/SingleTask.php | 14 ++++++++- Entity/Task/SingleTaskPlaceEvent.php | 13 ++++++++- .../migrations/Version20181113161925.php | 29 +++++++++++++++++++ .../migrations/Version20181113164108.php | 28 ++++++++++++++++++ 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 Resources/migrations/Version20181113161925.php create mode 100644 Resources/migrations/Version20181113164108.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 08632feaa..48c702bca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,3 +7,8 @@ Version 1.5.1 - add a filtering by center on list; - add color in boxes for task statuses; +Branch `master` +=============== + +- adding indexes on place event and task + diff --git a/Entity/SingleTask.php b/Entity/SingleTask.php index 10101f6cb..03c904497 100644 --- a/Entity/SingleTask.php +++ b/Entity/SingleTask.php @@ -9,7 +9,19 @@ use Doctrine\Common\Collections\Collection; /** * SingleTask * - * @ORM\Table("chill_task.single_task") + * @ORM\Table( + * "chill_task.single_task", + * indexes={ + * @ORM\Index( + * name="by_type", + * columns={ "type" } + * ), + * @ORM\Index( + * name="by_current_state", + * columns={ "current_states" } + * ) + * } + * ) * @ORM\Entity(repositoryClass="Chill\TaskBundle\Repository\SingleTaskRepository") */ class SingleTask extends AbstractTask diff --git a/Entity/Task/SingleTaskPlaceEvent.php b/Entity/Task/SingleTaskPlaceEvent.php index c2facea43..75dfd82d6 100644 --- a/Entity/Task/SingleTaskPlaceEvent.php +++ b/Entity/Task/SingleTaskPlaceEvent.php @@ -23,7 +23,18 @@ use Chill\TaskBundle\Entity\SingleTask; /** * * - * @ORM\Table("chill_task.single_task_place_event") + * @ORM\Table( + * "chill_task.single_task_place_event", + * indexes={ + * @ORM\Index( + * name="transition_task_date", + * columns={"task_id", "transition", "datetime"} + * ), + * @ORM\Index( + * name="transition_task", + * columns={"task_id", "transition"} + * ) + * }) * @ORM\Entity() * * @author Julien Fastré diff --git a/Resources/migrations/Version20181113161925.php b/Resources/migrations/Version20181113161925.php new file mode 100644 index 000000000..7b3ae95f4 --- /dev/null +++ b/Resources/migrations/Version20181113161925.php @@ -0,0 +1,29 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE INDEX transition_task_date ON chill_task.single_task_place_event (task_id, transition, datetime)'); + $this->addSql('CREATE INDEX transition_task ON chill_task.single_task_place_event (task_id, transition)'); + } + + public function down(Schema $schema) : void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('DROP INDEX transition_task_date'); + $this->addSql('DROP INDEX transition_task'); + + } +} diff --git a/Resources/migrations/Version20181113164108.php b/Resources/migrations/Version20181113164108.php new file mode 100644 index 000000000..48e22c597 --- /dev/null +++ b/Resources/migrations/Version20181113164108.php @@ -0,0 +1,28 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE INDEX by_type ON chill_task.single_task (type)'); + $this->addSql('CREATE INDEX by_current_state ON chill_task.single_task USING GIN (current_states)'); + } + + public function down(Schema $schema) : void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('DROP INDEX by_type'); + $this->addSql('DROP INDEX by_current_state'); + } +}