On 11/02/16 15:05, 'Hugo Osvaldo Barrera' via Django developers
(Contributions to Django itself) wrote:
> There was some research by Sebastian Vetter on "single-child
> auto-resolve" solutions for MTI and how they scaled (from memory,
> model-utils' InheritanceManager, polymorphic, and generic-m2m)
> https://github.com/elbaschid/mti-lightbulb
Django already uses MTI. The only difference I'm proposing is,
basically, making life simpler for those wanting to get all objects as
their native class, rather than parent class (while not affecting those
that don't use them).
I know Django uses MTI. This thread is, after all, talking about a tool
for a _specific_ use case of MTI.
This investigation was specifically comparing the _scalability_ of 3
solutions to the same problem.
The implementations differ as:
polymorphic:
- has a "hidden" content_type field to indicate which child model to
link for this "parent" record
- uses prefetch_related to resolve
- results in 1+N queries
InheritanceManager (admin-tools):-
- uses select_related to grab _all_ the child models
- selects the first one that exists
- always results in 1 query
- can blow your DB server's brains out with the number of joins (if you
have a couple of hundred child models).
- can select the "wrong" child if you somehow made two for the same parent
Generic M2M:
- quite a different solution, but could be used in the same way for
Seb's purposes.
- don't recall specifics
- scaled dramatically better than the other two
--
C
--
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 receiving emails from it, send an email
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/56BC2770.1090707%40tinbrain.net.
For more options, visit https://groups.google.com/d/optout.