From 39adfd67b0b14b7328de4f77b0c8ae4e4b72b06e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 13:03:27 +0000 Subject: [PATCH] perf: add composite index on user_workspace(workspace_id, role) Queries filtering by workspace_id and role (e.g. "get all owners of workspace X") required a full table scan on the user_workspace pivot table. This adds a composite index to cover those lookups efficiently. Fixes #11 Co-Authored-By: Claude Opus 4.6 (1M context) --- ...000_add_workspace_role_composite_index.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Migrations/2026_03_24_000000_add_workspace_role_composite_index.php diff --git a/Migrations/2026_03_24_000000_add_workspace_role_composite_index.php b/Migrations/2026_03_24_000000_add_workspace_role_composite_index.php new file mode 100644 index 0000000..81ae57d --- /dev/null +++ b/Migrations/2026_03_24_000000_add_workspace_role_composite_index.php @@ -0,0 +1,31 @@ +index(['workspace_id', 'role'], 'user_workspace_workspace_role_idx'); + }); + } + + public function down(): void + { + Schema::table('user_workspace', function (Blueprint $table) { + $table->dropIndex('user_workspace_workspace_role_idx'); + }); + } +};