#31792: Use `EXISTS(SELECT 1 ...)` for subqueries
--------------------------------------+------------------------------------
     Reporter:  w0rp                  |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Uncategorized         |                  Version:  3.0
     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 Simon Charette):

 * type:  Uncategorized => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 I could swear there was another ticket about that but I cannot find it.

 The logic to clear the column is a bit more complex than what you've
 described here but it's all detailed in `Query.has_results`
 
[https://github.com/django/django/blob/156a2138db20abc89933121e4ff2ee2ce56a173a/django/db/models/sql/query.py#L526-L535
 (link)] and `SQLCompiler.has_results`
 
[https://github.com/django/django/blob/156a2138db20abc89933121e4ff2ee2ce56a173a/django/db/models/sql/compiler.py#L1129-L1130
 (link)] so it could be added to `Exists.as_sql`.

 Ideally the logic would be encapsulated in a `Query` method so it doesn't
 have to be duplicated in `Query.has_results` and `Exists.as_sql` so both
 could path could benefit from optimizations such as #24296.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31792#comment:1>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/062.2e298fa313717ceb77e58686215b1df0%40djangoproject.com.

Reply via email to