Skip to content

Commit

Permalink
perf(CommonPlayersStrategy): add index to reduce suggestions bottleneck
Browse files Browse the repository at this point in the history
  • Loading branch information
wescopeland committed Jan 25, 2025
1 parent 6c00463 commit 27cdb09
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up(): void
{
Schema::table('player_games', function (Blueprint $table) {
$table->index([
'user_id',
'achievements_unlocked',
'achievements_total',
'deleted_at',
'game_id',
], 'idx_player_games_suggestions'); // custom name needed because the auto-generated one is too long
});
}

public function down(): void
{
Schema::table('player_games', function (Blueprint $table) {
$table->dropIndex('idx_player_games_suggestions');
});
}
};

0 comments on commit 27cdb09

Please sign in to comment.