From c863f6f81b600ff783af3855f21e5ada51b04177 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 28 May 2026 16:27:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(perf):=20resolve=20F-13=20=E2=80=94=20add?= =?UTF-8?q?=20database=20indexes=20on=20joined/filtered=20columns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...6_05_28_000000_add_performance_indexes.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/database/migrations/2026_05_28_000000_add_performance_indexes.php diff --git a/src/database/migrations/2026_05_28_000000_add_performance_indexes.php b/src/database/migrations/2026_05_28_000000_add_performance_indexes.php new file mode 100644 index 00000000..e3d3f621 --- /dev/null +++ b/src/database/migrations/2026_05_28_000000_add_performance_indexes.php @@ -0,0 +1,60 @@ +index('stationid', 'rainfall_stationid_index'); + $table->index('timestamp', 'rainfall_timestamp_index'); + $table->index(['stationid', 'timestamp'], 'rainfall_stationid_timestamp_index'); + }); + + Schema::table('waterlevel', function (Blueprint $table) { + $table->index('stationid', 'waterlevel_stationid_index'); + $table->index('datetime', 'waterlevel_datetime_index'); + $table->index(['stationid', 'datetime'], 'waterlevel_stationid_datetime_index'); + }); + + Schema::table('notification', function (Blueprint $table) { + $table->index('stationid', 'notification_stationid_index'); + $table->index('timestamp', 'notification_timestamp_index'); + $table->index('stationtype', 'notification_stationtype_index'); + }); + + Schema::table('siren', function (Blueprint $table) { + $table->index('stationid', 'siren_stationid_index'); + $table->index('active_time', 'siren_active_time_index'); + }); + } + + public function down(): void + { + Schema::table('rainfall', function (Blueprint $table) { + $table->dropIndex('rainfall_stationid_timestamp_index'); + $table->dropIndex('rainfall_timestamp_index'); + $table->dropIndex('rainfall_stationid_index'); + }); + + Schema::table('waterlevel', function (Blueprint $table) { + $table->dropIndex('waterlevel_stationid_datetime_index'); + $table->dropIndex('waterlevel_datetime_index'); + $table->dropIndex('waterlevel_stationid_index'); + }); + + Schema::table('notification', function (Blueprint $table) { + $table->dropIndex('notification_stationtype_index'); + $table->dropIndex('notification_timestamp_index'); + $table->dropIndex('notification_stationid_index'); + }); + + Schema::table('siren', function (Blueprint $table) { + $table->dropIndex('siren_active_time_index'); + $table->dropIndex('siren_stationid_index'); + }); + } +};