#30079: Prefetch cache should be aware of database source and .using() should 
not
always trigger a new query
-------------------------------------+-------------------------------------
     Reporter:  Mike Lissner         |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  prefetch,            |             Triage Stage:
  multidatabase                      |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mike Lissner):

 Replying to [comment:1 Carlton Gibson]:
 > On the basis of the difference between `ln64` and `ln65` I'm inclined to
 accept this. `pizza0` came from `replica` and the `ln64` call just goes
 with that. (That seems right/expected to me...) I see your point that
 adding the `using()` shouldn't change that.

 Good! I made myself clear. Always a good thing.

 > At first glance the ''"if you didn't add a `filter()`/`exclude()`"''
 idea seems OK too.

 That was my analysis too: "This seems to be a reasonable line in the
 sand."

 > Two questions though:
 >
 > 1. What's the use-case for re-adding the `using()` call in `ln65`? I
 can't quite see why you'd do that...? (Another way of looking at `using()`
 might be "go back to **this** DB"...)

 I can't make a really clear argument for my use case, but basically it
 was, "I'm doing weird things with prefetching and I want to be sure Django
 pulls this data properly from the right DB/cache." In other words, it was
 me trying to be explicit about where the caches were *supposed* come from,
 and then getting bit by having the caches busted. From my reading, ln64 is
 totally unclear which DB it would use since it would normally use the
 "default" DB, but had a cached value, so which wins? My solution was to be
 more explicit to make sure it used the cache, but that backfired (luckily,
 I was watching the query logs).

 > 2. Have you looked at all at what a patch might look like? (If it's
 simple enough, that helps...)

 No, not at all, unfortunately. I've looked into the Django code from time
 to time, but mostly I stay on my side of the API, lest I get in trouble.
 Especially when it comes to the ORM bits.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30079#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.3365298f0f81fa890d2798b2735c86a4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to