Caching related objects in serializer context. #8902
Unanswered
dharani7998
asked this question in
Ideas & Suggestions
Replies: 1 comment 3 replies
-
can you please share code snippets or examples please?? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using the serializer with a list of items, for each item the related object is fetched from the database even though the related instance is the same in multiple or all the items in the list.
If the related instances can be cached in the serializer context, it would save a lot of DB calls and save a lot of time when trying to load 1000s of items in one shot.
As we can see here for each item in the list, a new type_group instance is fetched and created. This can be avoided if the related instances are cached in the serializer context.
Beta Was this translation helpful? Give feedback.
All reactions