Re: Automatic prefetching in querysets

2020-03-25 Thread Gordon Wrigley
My existing code for this is now available as a pypi package https://github.com/tolomea/django-auto-prefetch -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop

Re: Sealing or locking QuerySets -- a suggestion to prevent surprise N+1 queries.

2018-01-08 Thread Gordon Wrigley
Regarding auto prefetch, after the discussion here I created a ticket https://code.djangoproject.com/ticket/28586 It didn't get much attention presumably because it was around Django 2 release time. I have a todo note to add tests and doco and generally get it to a mergable state in order to

Re: Automatic prefetching in querysets

2017-09-12 Thread Gordon Wrigley
This received some positive responses, so to help move the conversation along I have created a ticket and pull request. https://code.djangoproject.com/ticket/28586 https://github.com/django/django/pull/9064 Regards G On Tue, Aug 15, 2017 at 10:44 AM, Gordon Wrigley <gordon.wrig...@gmail.

Re: Automatic prefetching in querysets

2017-08-17 Thread Gordon Wrigley
I'm not advocating either way on this, but it's probably worth noting that the context manager proposal is compatible with a queryset level optin/out and an object level optout. So you could for example have prefetch_related(auto=None) which can be explicitly set to True / False and takes it's

Re: Automatic prefetching in querysets

2017-08-16 Thread Gordon Wrigley
Regarding 2, it does work for reverse one-to-one relations. On Wed, Aug 16, 2017 at 9:17 PM, Aymeric Augustin < aymeric.augus...@polytechnique.org> wrote: > On 15 Aug 2017, at 11:44, Gordon Wrigley <gordon.wrig...@gmail.com> wrote: > > I'd like to discuss automatic pre

Re: Automatic prefetching in querysets

2017-08-16 Thread Gordon Wrigley
or a >>>> pessimization. If I can come up with a single example where it would >>>> significantly decrease performance (either memory usage or speed) compared >>>> to the default (and I'm sure I can), then I would be strongly opposed to it >>>>

Re: Automatic prefetching in querysets

2017-08-15 Thread Gordon Wrigley
lution would be for Django to detect these O(n) query > cases and display intelligent warnings, with suggestions as to the correct > select/prefetch calls to add. When debug mode is enabled we could detect > repeated foreign key referencing from the same source. > > On 15 Aug 2017 19:44

Re: Automatic prefetching in querysets

2017-08-15 Thread Gordon Wrigley
t unlike Django where I have years of experience I have next to no experience with other ORM's. Regards G On Tue, Aug 15, 2017 at 7:44 PM, Gordon Wrigley <gordon.wrig...@gmail.com> wrote: > Sorry maybe I wasn't clear enough about the proposed mechanism. > > Currently when you d

Re: Automatic prefetching in querysets

2017-08-15 Thread Gordon Wrigley
15, 2017 at 8:03 PM, Collin Anderson <cmawebs...@gmail.com> wrote: > Hi Gordon, > > How is it implemented? Does each object keep a reference to the queryset > it came from? > > Collin > > On Tue, Aug 15, 2017 at 2:44 PM, Gordon Wrigley <gordon.wrig...@gmail.com>

Re: Automatic prefetching in querysets

2017-08-15 Thread Gordon Wrigley
any other ORMs which attempt similar magical optimisations? > How do they go about identifying the cases where it is necessary? > > On 15 August 2017 at 10:44, Gordon Wrigley <gordon.wrig...@gmail.com> > wrote: > >> I'd like to discuss automatic prefetching in querysets. Spec

Automatic prefetching in querysets

2017-08-15 Thread Gordon Wrigley
I'd like to discuss automatic prefetching in querysets. Specifically automatically doing prefetch_related where needed without the user having to request it. For context consider these three snippets using the Question & Choice models from the tutorial