From ad6bbee24e1ecedc6843e1bc41f06641f80e635c Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sun, 6 Oct 2024 15:43:34 -0500 Subject: [PATCH] Improve device ports loading speed (#16500) * Improve device ports loading speed Add port->vlans relationship index as discovered missing here: https://community.librenms.org/t/device-ports-page-delay-loading-due-to-slow-db-query/26207 * update db_schema.yaml --- ...33_ports_vlans_table_add_port_id_index.php | 28 +++++++++++++++++++ misc/db_schema.yaml | 1 + 2 files changed, 29 insertions(+) create mode 100644 database/migrations/2024_10_06_002633_ports_vlans_table_add_port_id_index.php diff --git a/database/migrations/2024_10_06_002633_ports_vlans_table_add_port_id_index.php b/database/migrations/2024_10_06_002633_ports_vlans_table_add_port_id_index.php new file mode 100644 index 0000000000..bf15b67f4a --- /dev/null +++ b/database/migrations/2024_10_06_002633_ports_vlans_table_add_port_id_index.php @@ -0,0 +1,28 @@ +index('port_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('ports_vlans', function (Blueprint $table) { + $table->dropIndex('ports_vlans_port_id_index'); + }); + } +}; diff --git a/misc/db_schema.yaml b/misc/db_schema.yaml index 24eb144ba8..e80df0b0a3 100644 --- a/misc/db_schema.yaml +++ b/misc/db_schema.yaml @@ -1794,6 +1794,7 @@ ports_vlans: Indexes: PRIMARY: { Name: PRIMARY, Columns: [port_vlan_id], Unique: true, Type: BTREE } ports_vlans_device_id_port_id_vlan_unique: { Name: ports_vlans_device_id_port_id_vlan_unique, Columns: [device_id, port_id, vlan], Unique: true, Type: BTREE } + ports_vlans_port_id_index: { Name: ports_vlans_port_id_index, Columns: [port_id], Unique: false, Type: BTREE } port_groups: Columns: - { Field: id, Type: 'int unsigned', 'Null': false, Extra: auto_increment }