From a6154dcf8027a68c150b2b27613da268f7732e6d Mon Sep 17 00:00:00 2001 From: Rob Bradley Date: Mon, 4 May 2020 23:33:45 -0400 Subject: [PATCH 1/2] Add index to created_at When the `telescope_entries` table gets large, `telescope:prune` will fail miserably, actually bringing an AWS db instance to its knees. This is because `telescope:prune` is using `created_at` in a where clause when there's no index on that column. --- .../2018_08_08_100000_create_telescope_entries_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/migrations/2018_08_08_100000_create_telescope_entries_table.php b/src/Storage/migrations/2018_08_08_100000_create_telescope_entries_table.php index 64c562e8e..b0bef9fbd 100644 --- a/src/Storage/migrations/2018_08_08_100000_create_telescope_entries_table.php +++ b/src/Storage/migrations/2018_08_08_100000_create_telescope_entries_table.php @@ -48,7 +48,7 @@ public function up() $table->boolean('should_display_on_index')->default(true); $table->string('type', 20); $table->longText('content'); - $table->dateTime('created_at')->nullable(); + $table->dateTime('created_at')->nullable()->index(); $table->unique('uuid'); $table->index('batch_id'); From 8fb995586f807905e240a8c2e426193eb714bca1 Mon Sep 17 00:00:00 2001 From: Rob Bradley Date: Tue, 5 May 2020 01:21:44 -0400 Subject: [PATCH 2/2] Group indices Grouped indices based on @barryvdh feedback --- .../2018_08_08_100000_create_telescope_entries_table.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Storage/migrations/2018_08_08_100000_create_telescope_entries_table.php b/src/Storage/migrations/2018_08_08_100000_create_telescope_entries_table.php index b0bef9fbd..88c43cbdc 100644 --- a/src/Storage/migrations/2018_08_08_100000_create_telescope_entries_table.php +++ b/src/Storage/migrations/2018_08_08_100000_create_telescope_entries_table.php @@ -44,14 +44,16 @@ public function up() $table->bigIncrements('sequence'); $table->uuid('uuid'); $table->uuid('batch_id'); - $table->string('family_hash')->nullable()->index(); + $table->string('family_hash')->nullable(); $table->boolean('should_display_on_index')->default(true); $table->string('type', 20); $table->longText('content'); - $table->dateTime('created_at')->nullable()->index(); + $table->dateTime('created_at')->nullable(); $table->unique('uuid'); $table->index('batch_id'); + $table->index('family_hash'); + $table->index('created_at'); $table->index(['type', 'should_display_on_index']); });