Add missing index for device_perf (#11974)

Makes the latency page load faster in case of a large device_perf table
This commit is contained in:
Jellyfrog
2020-07-31 16:07:00 +02:00
committed by GitHub
parent 973a39a0ac
commit cf13e92f05
2 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDevicePerfIndex extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('device_perf', function (Blueprint $table) {
$table->index(['device_id', 'timestamp']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('device_perf', function (Blueprint $table) {
$table->dropIndex(['device_id', 'timestamp']);
});
}
}

View File

@@ -605,6 +605,7 @@ device_perf:
Indexes:
PRIMARY: { Name: PRIMARY, Columns: [id], Unique: true, Type: BTREE }
device_perf_device_id_index: { Name: device_perf_device_id_index, Columns: [device_id], Unique: false, Type: BTREE }
device_perf_device_id_timestamp_index: { Name: device_perf_device_id_timestamp_index, Columns: [device_id, timestamp], Unique: false, Type: BTREE }
device_relationships:
Columns:
- { Field: parent_device_id, Type: 'int unsigned', 'Null': false, Extra: '', Default: '0' }