Replies: 1 comment
-
Prefetching is a topic which needs to be improved within DJA however it is also not an easy task. Best take a look at discussion #921 to see what approaches are being discussed, and there are also some code bits and PRs referenced. My feeling is that we should make auto prefetching as best as possible. But when it cannot cover what is needed, it should be possible to simply disable it and a DJA user can then do their own optimization within their code (like overwriting |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
At the moment, we have
select_for_includes
andprefetch_for_includes
for dynamic prefetching and selecting. I was wondering if there is anything similar for thefields[resource]
parameter (I believe there is not) since I'm adding some metadata to my resources:In this case, I make a new DB query on every resource that the API returns, since this requires checking if the resource is in the user's library. This query can be omitted if the user is not logged in or the request has
fields[resource]
withoutuser
as a query parameter, but I'd like to prefetch the related resources only if the field is present.ATM, I need to decide whether to prefetch all the users or none of them and make an extra query. Is there any way to accomplish this or not?
My suggestion in case this is not yet possible is to add a
prefetch_for_fields
andselect_for_fields
which would work exactly as the currentprefetch_for_fields
andselect_for_fields
.Note: After writing this I realized I can avoid making a new DB query using
values_list
.Beta Was this translation helpful? Give feedback.
All reactions