Fixed #34580 -- Avoided unnecessary computation of selected expressions in SQLCompiler.
Performance regression in 278881e37619278789942513916acafaa88d26f3. Co-authored-by: David Smith <smithdc@gmail.com>
This commit is contained in:
parent
00f5d2d110
commit
98f6ada0e2
@ -331,7 +331,9 @@ class SQLCompiler:
|
|||||||
default_order, _ = ORDER_DIR["DESC"]
|
default_order, _ = ORDER_DIR["DESC"]
|
||||||
|
|
||||||
selected_exprs = {}
|
selected_exprs = {}
|
||||||
if select := self.select:
|
# Avoid computing `selected_exprs` if there is no `ordering` as it's
|
||||||
|
# relatively expensive.
|
||||||
|
if ordering and (select := self.select):
|
||||||
for ordinal, (expr, _, alias) in enumerate(select, start=1):
|
for ordinal, (expr, _, alias) in enumerate(select, start=1):
|
||||||
pos_expr = PositionRef(ordinal, alias, expr)
|
pos_expr = PositionRef(ordinal, alias, expr)
|
||||||
if alias:
|
if alias:
|
||||||
|
@ -22,3 +22,6 @@ Bugfixes
|
|||||||
|
|
||||||
* Fixed a bug in Django 4.2 where :option:`makemigrations --update` didn't
|
* Fixed a bug in Django 4.2 where :option:`makemigrations --update` didn't
|
||||||
respect the ``--name`` option (:ticket:`34568`).
|
respect the ``--name`` option (:ticket:`34568`).
|
||||||
|
|
||||||
|
* Fixed a performance regression in Django 4.2 when compiling queries without
|
||||||
|
ordering (:ticket:`34580`).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user