[Django] #24296: clear select fields for `.exists()` of distinct, non-sliced querysets

26 views
Skip to first unread message

Django

unread,
Feb 6, 2015, 8:29:05 PM2/6/15
to django-...@googlegroups.com
#24296: clear select fields for `.exists()` of distinct, non-sliced querysets
----------------------------------------------+--------------------
Reporter: outofculture | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Database layer (models, ORM) | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
The fix (93cc6dcdac6fc3e506640fa38dd1798c3cd61cff) for bug #18414
introduced an inefficiency in `.exists()` on distinct querysets in that
now all distinct querysets are selecting all their fields. I propose the
fields should be left on the queryset only if `(q.distinct and
(q.high_mark is not None or q.low_mark is not None))`.

As I started writing the test for this, I realized I would have to inspect
the query itself, which seems... like a bad idea for a test. Would this be
reasonable to submit the (one-line-change) patch without a test, or does
someone have a suggestion for a way to make the test that's less brittle?

--
Ticket URL: <https://code.djangoproject.com/ticket/24296>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 2, 2015, 6:06:13 PM3/2/15
to django-...@googlegroups.com
#24296: clear select fields for `.exists()` of distinct, non-sliced querysets
-------------------------------------+-------------------------------------
Reporter: outofculture | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

A test that inspects the query is likely fine. See if you can find an
existing test that does something similar.

--
Ticket URL: <https://code.djangoproject.com/ticket/24296#comment:1>

Django

unread,
Apr 11, 2022, 8:23:22 AM4/11/22
to django-...@googlegroups.com
#24296: clear select fields for `.exists()` of distinct, non-sliced querysets
-------------------------------------+-------------------------------------
Reporter: Martin Chase | Owner: Marcelo
Type: | Galigniana
Cleanup/optimization | Status: assigned

Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Marcelo Galigniana):

* owner: nobody => Marcelo Galigniana
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/24296#comment:2>

Django

unread,
Apr 11, 2022, 8:35:56 AM4/11/22
to django-...@googlegroups.com
#24296: clear select fields for `.exists()` of distinct, non-sliced querysets
-------------------------------------+-------------------------------------
Reporter: Martin Chase | Owner: Marcelo
Type: | Galigniana
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Marcelo Galigniana):

[https://github.com/django/django/pull/15576 PR was created]

--
Ticket URL: <https://code.djangoproject.com/ticket/24296#comment:3>

Django

unread,
Apr 12, 2022, 2:20:18 AM4/12/22
to django-...@googlegroups.com
#24296: clear select fields for `.exists()` of distinct, non-sliced querysets
-------------------------------------+-------------------------------------
Reporter: Martin Chase | Owner: Marcelo
Type: | Galigniana
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/24296#comment:4>

Django

unread,
Apr 12, 2022, 5:41:23 AM4/12/22
to django-...@googlegroups.com
#24296: clear select fields for `.exists()` of distinct, non-sliced querysets
-------------------------------------+-------------------------------------
Reporter: Martin Chase | Owner: Marcelo
Type: | Galigniana
Cleanup/optimization | Status: closed

Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"0ad5316f22eabe8fa8b22dc92e61170cfacc3c78" 0ad5316f]:
{{{
#!CommitTicketReference repository=""
revision="0ad5316f22eabe8fa8b22dc92e61170cfacc3c78"
Fixed #24296 -- Made QuerySet.exists() clear selected columns for not
sliced distinct querysets.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24296#comment:5>

Reply all
Reply to author
Forward
0 new messages