Skip to content

Commit 86e4c08

Browse files
committed
perf(webapp): look up environments by indexed organization column
The metric endpoint built its environment field mappings with a `where: { project: { organizationId } }` filter, which joins through the projects table on every request. RuntimeEnvironment has its own non-null, indexed organizationId column that is always set to the same organization as the environment's project, so filter on it directly instead. Returns the same set of environments with less work per request. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B6byUe71HjFpnGAsicw7Hy
1 parent 8f66af6 commit 86e4c08

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: improvement
4+
---
5+
6+
Dashboard charts load with less database work behind the scenes

apps/webapp/app/services/queryService.server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ export async function executeQuery<TOut extends z.ZodSchema>(
359359
});
360360

361361
const environments = await prisma.runtimeEnvironment.findMany({
362-
where: { project: { organizationId } },
362+
// Same set as filtering through `project`, but hits the indexed column without the join.
363+
where: { organizationId },
363364
select: { id: true, slug: true },
364365
});
365366

0 commit comments

Comments
 (0)