Rough orders of magnitude are
Query Count 1.257ms -> 1.849ms 47% Increase
Aggregate 0.882ms -> 1.238ms 40% Increase
I managed to bisect the regression to this commit
https://github.com/django/django/commit/278881e3 |
278881e37619278789942513916acafaa88d26f3
--
Ticket URL: <https://code.djangoproject.com/ticket/34580>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Simon Charette (added)
* type: Uncategorized => Cleanup/optimization
* component: Uncategorized => Database layer (models, ORM)
Comment:
Thanks for the report, can you point at the exact test definition that
regressed otherwise it's quite hard to confirm what actually got slower
Is this
[https://github.com/django/djangobench/blob/4c88fa81c4d7618604ae51e07c03c23f6734c2e6/djangobench/benchmarks/query_count/benchmark.py
query_count] and
[https://github.com/django/djangobench/blob/4c88fa81c4d7618604ae51e07c03c23f6734c2e6/djangobench/benchmarks/query_aggregate/benchmark.py#L12
aggregate]?
If that's the case then I'm surprised this particular commit caused a
regression in these `Count` tests as none of them make use or ordering. If
that's truly the culprit then it's likely only a matter of not generating
`selected_exprs` if there is no `ordering` in the first place.
--
Ticket URL: <https://code.djangoproject.com/ticket/34580#comment:1>
Comment (by David Smith):
I attempted to see if the benchmark workflow could detect the changes from
the propose patch in [https://github.com/django/django/pull/16882 PR ].
Unfortunately it could not.
However, running locally I can see a performance improvement in the region
of 20-30% from the proposed change. I was able to repeat this, and see a
similar improvement a second time.
{{{
before after ratio
[ca5d3c99] [2aa6996a]
<form_docs> <SQLCompiler>
- 1.83±0.01ms 1.41±0.01ms 0.77
query_benchmarks.query_exists.benchmark.QueryExists.time_query_exists
- 874±2μs 621±8μs 0.71
query_benchmarks.query_aggregate.benchmark.QueryAggr.time_aggregate
- 1.35±0.02ms 905±4μs 0.67
query_benchmarks.query_count.benchmark.QueryCount.time_query_count
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34580#comment:2>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/34580#comment:3>
* owner: nobody => David Smith
* status: new => assigned
* severity: Normal => Release blocker
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/34580#comment:4>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34580#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"98f6ada0e2058d67d91fb6c16482411ec2ca0967" 98f6ada]:
{{{
#!CommitTicketReference repository=""
revision="98f6ada0e2058d67d91fb6c16482411ec2ca0967"
Fixed #34580 -- Avoided unnecessary computation of selected expressions in
SQLCompiler.
Performance regression in 278881e37619278789942513916acafaa88d26f3.
Co-authored-by: David Smith <smi...@gmail.com>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34580#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"e1c00f8b361bf89deb68733bbc5189734bbcd6b5" e1c00f8]:
{{{
#!CommitTicketReference repository=""
revision="e1c00f8b361bf89deb68733bbc5189734bbcd6b5"
[4.2.x] Fixed #34580 -- Avoided unnecessary computation of selected
expressions in SQLCompiler.
Performance regression in 278881e37619278789942513916acafaa88d26f3.
Co-authored-by: David Smith <smi...@gmail.com>
Backport of 98f6ada0e2058d67d91fb6c16482411ec2ca0967 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34580#comment:7>