Re: [Django] #20535: Unnecessary join created for intermediate table between two M2M tables

2019-06-24 Thread Django
#20535: Unnecessary join created for intermediate table between two M2M tables
-+-
 Reporter:  German M. Bravo  |Owner:  (none)
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Can Sarıgöl):

 * status:  assigned => new
 * needs_better_patch:  0 => 1
 * owner:  Can Sarıgöl => (none)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.54bec0609753ce5e6f9e3a3d44c57dda%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #20535: Unnecessary join created for intermediate table between two M2M tables

2019-06-24 Thread Django
#20535: Unnecessary join created for intermediate table between two M2M tables
-+-
 Reporter:  German M. Bravo  |Owner:  Can
 |  Sarıgöl
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Can Sarıgöl):

 * status:  new => assigned
 * needs_better_patch:  1 => 0
 * owner:  nobody => Can Sarıgöl


Comment:

 [https://github.com/django/django/pull/11510 PR]

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.2d52dbe7a1e67bd1fbb0d98ca0e32c41%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #20535: Unnecessary join created for intermediate table between two M2M tables

2017-10-18 Thread Django
#20535: Unnecessary join created for intermediate table between two M2M tables
-+-
 Reporter:  German M. Bravo  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Zach):

 * cc: Zach (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.884ea50a7daf4161e0861b1db4a13605%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #20535: Unnecessary join created for intermediate table between two M2M tables

2013-06-16 Thread Django
#20535: Unnecessary join created for intermediate table between two M2M tables
-+-
 Reporter:  Kronuz   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:   |  Needs documentation:  0
Has patch:  1|  Patch needs improvement:  1
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-
Changes (by akaariai):

 * needs_better_patch:  0 => 1
 * stage:  Unreviewed => Accepted


Comment:

 Yes, skipping non-necessary intermediate joins would be good.
 Unfortunately the added patch seems to introduce a lot of errors in the
 test suite.

 Maybe it would be better to do the trimming at compiler.get_from_clause()
 time? A join can be skipped if there are as many tables joining to it as
 its alias_refcount is, and every joined table can be joined directly to
 the "parent" table instead.

 Trimming joins before joins promotion is done is a bad idea. I am not sure
 if this applies to internal join trimming though.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.88c6c4a9807aab513c3a37f9200b4088%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #20535: Unnecessary join created for intermediate table between two M2M tables

2013-06-01 Thread Django
#20535: Unnecessary join created for intermediate table between two M2M tables
-+-
 Reporter:  Kronuz   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:
 Keywords:   |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Kronuz):

 * version:  1.5 => master


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.7e9a3d68de4763391667a25bffb16209%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #20535: Unnecessary join created for intermediate table between two M2M tables

2013-06-01 Thread Django
#20535: Unnecessary join created for intermediate table between two M2M tables
-+-
 Reporter:  Kronuz   |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.5
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:
 Keywords:   |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Kronuz):

 * needs_better_patch:   => 0
 * has_patch:  0 => 1
 * needs_tests:   => 0
 * needs_docs:   => 0


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.512c9798ac27608245d68b9e031140c0%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[Django] #20535: Unnecessary join created for intermediate table between two M2M tables

2013-05-31 Thread Django
#20535: Unnecessary join created for intermediate table between two M2M tables
--+
 Reporter:  Kronuz|  Owner:  nobody
 Type:  Bug   | Status:  new
Component:  Database layer (models, ORM)  |Version:  1.5
 Severity:  Normal|   Keywords:
 Triage Stage:  Unreviewed|  Has patch:  0
Easy pickings:  0 |  UI/UX:  0
--+
 In this example:
 {{{#!python
 from django.db import models

 class Person(models.Model):
 name = models.CharField(max_length=128)
 friends = models.ManyToManyField('self', symmetrical=False,
 through='Relationship')

 def __unicode__(self):
 return self.name

 class Relationship(models.Model):
 from_person = models.ForeignKey(Person, related_name='idols')
 to_person = models.ForeignKey(Person, related_name='followers')
 }}}

 Example data for a test:
 {{{#!python
 ringo, _ = Person.objects.get_or_create(name="Ringo Starr")
 paul, _ = Person.objects.get_or_create(name="Paul McCartney")
 george, _ = Person.objects.get_or_create(name="George Harrison")
 john, _ = Person.objects.get_or_create(name="John Lennon")
 yoko, _ = Person.objects.get_or_create(name="Yoko Ono")

 Relationship.objects.get_or_create(from_person=ringo, to_person=paul)
 Relationship.objects.get_or_create(from_person=george, to_person=john)
 Relationship.objects.get_or_create(from_person=paul, to_person=ringo)
 Relationship.objects.get_or_create(from_person=paul, to_person=george)
 Relationship.objects.get_or_create(from_person=paul, to_person=john)
 Relationship.objects.get_or_create(from_person=john, to_person=paul)
 Relationship.objects.get_or_create(from_person=john, to_person=yoko)
 Relationship.objects.get_or_create(from_person=yoko, to_person=john)
 }}}

 Then doing (get idols of the idols of paul):
 {{{#!python
 print
 Relationship.objects.filter(from_person__followers__from_person=paul).query
 }}}

 This produces a join between `Relationship` and `Person`, then to
 `Relationship`, then to `Person`. The final join (to `Person`) gets
 trimmed by `trim_joins()` after the `setup_joins()` in
 `Query.add_filter()`. However, the unneeded join with `Person` (between
 the two joined `Relationship`) is not removed. This produces something
 like:
 {{{#!sql
 SELECT ... FROM relationship INNER JOIN person ON
 (relationship.from_person_id = person.id) INNER JOIN relationship T3 ON
 (person.id = T3.to_person_id) WHERE T3.from_person_id = 2;
 }}}

 When in fact all that would be needed is:
 {{{#!sql
 SELECT ... FROM relationship INNER JOIN relationship T3 ON
 (relationship.from_person_id = T3.to_person_id) WHERE T3.from_person_id =
 2
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.21c86cb417f7dd3af5cb11b4704e7985%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.