Skip to content

Commit

Permalink
Improve device ports loading speed (librenms#16500)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
murrant authored Oct 6, 2024
1 parent 4dd3692 commit ad6bbee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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');
});
}
};
1 change: 1 addition & 0 deletions misc/db_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit ad6bbee

Please sign in to comment.