Skip to content

Conversation

bor3ham
Copy link
Contributor

@bor3ham bor3ham commented May 30, 2016

Some options to reduce the number of queries made when using relationships.

Currently the number of db queries made explodes out when either:

  • Including just the primary key as a field in a serializer, without actually "including" it
  • Actually "including" relationships

without prefetching on the viewset's queryset. For complicated models it can be very expensive to defensively prefetch everything every time, so these changes attempt to only fetch them from the db when needed.

bor3ham added 4 commits May 30, 2016 12:04
Rather than making another query to fetch the object for every result.
The validation here is awkward (following the relationships through
the model fields), I couldn't find a better way to ensure the
included args exist for a django prefetch rather than erroring out.
@bor3ham
Copy link
Contributor Author

bor3ham commented Aug 4, 2016

Rebased and patched over at:
#264

@bor3ham bor3ham closed this Aug 4, 2016
@bor3ham bor3ham deleted the optimize/relationship-extraction branch August 4, 2016 05:17
@bor3ham bor3ham restored the optimize/relationship-extraction branch August 4, 2016 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant