#32711: MySQL performance regression in
forms.models.apply_limit_choices_to_to_formfield
------------------------------------+--------------------------------------
     Reporter:  Thomas Achtemichuk  |                    Owner:  nobody
         Type:  Uncategorized       |                   Status:  closed
    Component:  Forms               |                  Version:  3.2
     Severity:  Normal              |               Resolution:  worksforme
     Keywords:                      |             Triage Stage:  Unreviewed
    Has patch:  0                   |      Needs documentation:  0
  Needs tests:  0                   |  Patch needs improvement:  0
Easy pickings:  0                   |                    UI/UX:  0
------------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

 * cc: Adam Johnson (added)
 * status:  new => closed
 * resolution:   => worksforme


Comment:

 Thanks for the report, however I cannot reproduce this issue on MySQL
 8.0.23. All indexes are used correctly:
 {{{
 >>> User.objects.filter(Exists(User.objects.filter(Q(pk=OuterRef('pk')) &
 Q(is_staff=True) & Q(groups__name='group_480')))).explain(analyze=True)

 -> Nested loop inner join  (cost=4.20 rows=4) (actual time=0.110..0.138
 rows=2 loops=1)
     -> Nested loop inner join  (cost=2.80 rows=4) (actual
 time=0.081..0.109 rows=4 loops=1)
         -> Index lookup on U1 using
 auth_user_groups_group_id_97559544_fk_auth_group_id (group_id='481')
 (cost=1.40 rows=4) (actual time=0.058..0.065 rows=4 loops=1)
         -> Single-row index lookup on auth_user using PRIMARY
 (id=U1.user_id)  (cost=0.28 rows=1) (actual time=0.009..0.010 rows=1
 loops=4)
     -> Filter: (0 <> U0.is_staff)  (cost=0.27 rows=1) (actual
 time=0.006..0.006 rows=0 loops=4)
         -> Single-row index lookup on U0 using PRIMARY (id=U1.user_id)
 (cost=0.27 rows=1) (actual time=0.004..0.005 rows=1 loops=4)
 }}}

 It looks that you don't have an index on `auth_user.id`, but I don't know
 why.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32711#comment:1>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.b0cb3dc4159fcf28f3016373bff42eb2%40djangoproject.com.

Reply via email to