#32632: Query resolution can be at least 3x slower in 3.2
-------------------------------------+-------------------------------------
               Reporter:  mrfleap    |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  3.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I recently upgraded to Django 3.2 from 3.1.8 and found running my queries
 were taking nearly 15 seconds to run compared to a few milliseconds in
 3.1.8. To help bring this issue to light I've created a basic Django
 project on GitHub with a test case that shows this issue. Running
 "manage.py test" on Django 3.2 and Django 3.1.8 shows that 3.2 is taking
 roughly 3x as long to build the query, while not executing the query.

 Repository with test case: https://github.com/mrfleap/django-db-test

 The underlying query is admittedly repetitive, but I still feel it this
 degradation in performance should not go overlooked. Through some basic
 debugging I believe the issue may lie django/utils/tree.py on line 93
 (https://github.com/django/django/blob/stable/3.2.x/django/utils/tree.py#L93)
 where it checks to see if a node is within a list of children, one of my
 basic tests found the operation to take 9 seconds alone, rather than the
 fractions of a millisecond it usually takes. I've attached a screenshot of
 my breakpoint to showcase that it's taking ~9 seconds to determine if one
 node exists in an array of two.

 I'd also like to point out that I am using Django Guardian quite heavily
 in this scenario, which is leading to the complicated query in the first
 place. However, as far as I am aware, there is no difference in the
 generated query between both versions, and the difference in speed is
 based on how Django is resolving the internal objects into a SQL
 statement.

 Please let me know if there's any other information I can provide to help
 fix this issue.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32632>
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/050.648a148b61593c98f8036ff2ca72cfe9%40djangoproject.com.

Reply via email to