Skip to content

Conversation

@stsewd
Copy link
Member

@stsewd stsewd commented Aug 7, 2025

Django 4.2 added support for slices when prefetching. This results in a better query plan Sort (cost=287.47..287.52 rows=18 width=1420) -> Subquery Scan on qualify (cost=73.48..74.02 rows=12 width=1420), and also performs better in production

# before
6.07 s ± 10.7 ms per loop (mean ± std. dev. of 5 runs, 5 loops each)
# after
4.61 s ± 197 ms per loop (mean ± std. dev. of 5 runs, 5 loops each)

@stsewd stsewd requested a review from a team as a code owner August 7, 2025 17:39
@stsewd stsewd requested a review from ericholscher August 7, 2025 17:39
@stsewd stsewd merged commit 6676ed5 into main Aug 11, 2025
7 checks passed
@stsewd stsewd deleted the dont-use-subquery branch August 11, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants