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
This commit is contained in:
Tony Murray
2024-10-06 15:43:34 -05:00
committed by GitHub
parent 4dd369294e
commit ad6bbee24e
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('ports_vlans', function (Blueprint $table) {
$table->index('port_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('ports_vlans', function (Blueprint $table) {
$table->dropIndex('ports_vlans_port_id_index');
});
}
};

View File

@ -1794,6 +1794,7 @@ ports_vlans:
Indexes: Indexes:
PRIMARY: { Name: PRIMARY, Columns: [port_vlan_id], Unique: true, Type: BTREE } 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_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: port_groups:
Columns: Columns:
- { Field: id, Type: 'int unsigned', 'Null': false, Extra: auto_increment } - { Field: id, Type: 'int unsigned', 'Null': false, Extra: auto_increment }