-
Notifications
You must be signed in to change notification settings - Fork 1
Optimize Feed Query N+1 Problem #38
Copy link
Copy link
Open
Labels
backendBackend/API workBackend/API workbugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or requestintermediateIntermediate levelIntermediate level
Description
Activity
Metadata
Metadata
Assignees
Labels
backendBackend/API workBackend/API workbugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or requestintermediateIntermediate levelIntermediate level
Description
The feed page makes 30+ database queries per page due to N+1 query problems - each post triggers separate queries for likes, comments, and user data.
Steps to Reproduce
Expected Behavior
The feed should use at most 3-5 queries regardless of the number of posts, using select_related and prefetch_related for all related data.
Root Cause
The feed view doesn't use select_related for user and prefetch_related for likes, comments, or �ttachments.
Files to Fix
Acceptance Criteria