Small correction, prefetch_related doesn't issue any JOIN unless a is query with a select_related is specified with a Prefetch object.
Simon Le jeudi 21 mai 2015 17:53:30 UTC-4, Ash Christopher a écrit : > > Hi David, > > *select_related* does a JOIN under the hood, and you can't do > cross-database joins in the databases supported by Django. For > prefetch_related, there is no way out of the box to perform a > cross-database join in Python (which is what prefetch_related is doing) but > perhaps there is some way to programatically make that happen. I haven't > put any effort into exploring that idea. > > Thanks, > > On Thu, May 21, 2015 at 3:42 PM, David <[email protected] <javascript:>> > wrote: > >> Dear List, >> >> I came about conflicting information (to my mind) concerning the use of >> select_related() and prefetch_related(). >> My question is whether you can combine select_related() and >> prefetch_related() with sharding techniques. If so, how are you doing it? >> >> Background: >> I was watching various videos on Django under load and Django scaling, >> generally there comes a point at which they point at database sharding. >> Ash Christopher (https://www.youtube.com/watch?v=frlsGUHYu04) points out >> that as you use multiple databases with your Application, >> select_related() and prefetch_related() can no longer be used. In >> Christophe Pettus' videos I have not found such a comment, in fact >> select_related() and prefetch_related() seem to be habitually >> recommended to speed database connections up. >> >> Thanks for your insights! >> >> David >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/93fccd09-9d66-4e95-b242-7a8f81254726%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

