Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/plane/api/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_queryset(self):
)
| Q(network=2)
)
.select_related("workspace", "workspace__owner", "default_assignee", "project_lead")
.select_related("project_lead")
Comment thread
dheeru0198 marked this conversation as resolved.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Reintroduce eager loading for workspace/default_assignee to avoid N+1 queries

With this change the list endpoint stops preloading workspace, workspace__owner, and default_assignee. Any client that uses the documented expand parameter (or the serializer’s default fields) now triggers one extra query per project for each of those relations, undoing the optimization we previously had. That’s a significant performance regression for a list API that can easily return dozens of projects. Please keep those relations in select_related (or replace them with an equivalent prefetch strategy) so the endpoint remains O(1) queries.

-            .select_related("project_lead")
+            .select_related("workspace", "workspace__owner", "default_assignee", "project_lead")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.select_related("project_lead")
.select_related("workspace", "workspace__owner", "default_assignee", "project_lead")
🤖 Prompt for AI Agents
In apps/api/plane/api/views/project.py around line 82, the query no longer
eager-loads workspace, workspace__owner, and default_assignee which causes N+1
queries on the list endpoint; restore those relations to the queryset (e.g. add
them back into select_related or use an equivalent prefetch_related for
m2m/lookups) so the endpoint remains O(1) queries when returning many projects,
ensuring workspace, workspace__owner, and default_assignee are included in the
eager-loading set.

.annotate(
is_member=Exists(
ProjectMember.objects.filter(
Expand Down