-
-
Notifications
You must be signed in to change notification settings - Fork 612
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the Bug
As the title says - if have the only optimization enabled and I optimize a queryset that is prefetched, it is going to cause N+1, problem because the id field that is used to matched the prefetch objects is excluded from the queryset.
Not sure if it's a bug or expected behaviour but I spend some time debugging it ๐ . I solved the problem by disabling the only optimization, by passing the config instance to the optimize.
If it's not a bug I'd appreciate a more specific documentation on optimizer ๐
prefetched_fields: list[SomeFieldType] = strawberry_django.field(
prefetch_related=lambda info: Prefetch(
"some_fields",
queryset=optimize(SomeField.objects.filter(...)),
to_attr="prefetched_fields"
)
)System Information
- Operating system: MacOs 14.8 (23J21)
- Python version: 3.12
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working