From 1aaa6f6907d551d8ad0a6068c0290a0fadaffb4a Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Wed, 7 Feb 2024 17:15:24 +0100 Subject: [PATCH] Add caching for network sections and add indexes for order tables --- application/Network/Network.php | 7 ++- .../20240207155725_add_indexes_for_order.php | 46 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 db/migrations/20240207155725_add_indexes_for_order.php diff --git a/application/Network/Network.php b/application/Network/Network.php index e783d69a7..8fc81c670 100644 --- a/application/Network/Network.php +++ b/application/Network/Network.php @@ -125,7 +125,12 @@ class Network extends mfBaseModel { } if($name == "sections") { - $this->sections = NetworksectionModel::search(['network_id' => $this->id]); + $cache_key = "network_".$this->id."_sections"; + $this->sections = mfValuecache::singleton()->get($cache_key); + if($this->sections === NULL) { + $this->sections = NetworksectionModel::search(['network_id' => $this->id]); + mfValuecache::singleton()->set($cache_key, $this->sections); + } return $this->sections; } diff --git a/db/migrations/20240207155725_add_indexes_for_order.php b/db/migrations/20240207155725_add_indexes_for_order.php new file mode 100644 index 000000000..8f98f9780 --- /dev/null +++ b/db/migrations/20240207155725_add_indexes_for_order.php @@ -0,0 +1,46 @@ +getEnvironment() == "thetool") { + $this->execute("ALTER TABLE `ProducttechAttribute` ADD INDEX `producttech_id` (`producttech_id`)"); + $this->execute("ALTER TABLE `Worker` ADD INDEX `username` (`username`)"); + $this->execute("ALTER TABLE `OrderProduct` ADD INDEX `order_id` (`order_id`)"); + $this->execute("ALTER TABLE `Patching` ADD INDEX `termination_id` (`termination_id`)"); + $this->execute("ALTER TABLE `OrderJournal` ADD INDEX `order_id` (`order_id`)"); + $this->execute("ALTER TABLE `OrderFile` ADD INDEX `file_id` (`file_id`)"); + $this->execute("ALTER TABLE `OrderFile` ADD INDEX `order_id` (`order_id`)"); + $this->execute("ALTER TABLE `Networksection` ADD INDEX `network_id` (`network_id`)"); + $this->execute("ALTER TABLE `WorkerPermission` ADD INDEX `worker_id` (`worker_id`)"); + $this->execute("ALTER TABLE `WorkerFlag` ADD INDEX `network_id` (`worker_id`)"); + } + + if ($this->getEnvironment() == "addressdb") { + } + } + + public function down(): void + { + if ($this->getEnvironment() == "thetool") { + $this->execute("ALTER TABLE `ProducttechAttribute` DROP INDEX `producttech_id`"); + $this->execute("ALTER TABLE `Worker` DROP INDEX `username`"); + $this->execute("ALTER TABLE `OrderProduct` DROP INDEX `order_id`"); + $this->execute("ALTER TABLE `Patching` DROP INDEX `termination_id`"); + $this->execute("ALTER TABLE `OrderJournal` DROP INDEX `order_id`"); + $this->execute("ALTER TABLE `OrderFile` DROP INDEX `file_id`"); + $this->execute("ALTER TABLE `OrderFile` DROP INDEX `order_id`"); + $this->execute("ALTER TABLE `Networksection` DROP INDEX `network_id`"); + $this->execute("ALTER TABLE `WorkerPermission` DROP INDEX `worker_id`"); + $this->execute("ALTER TABLE `WorkerFlag` DROP INDEX `worker_id`"); + } + + if ($this->getEnvironment() == "addressdb") { + } + } +}