Changes between Initial Version and Version 1 of Ticket #31507
- Timestamp:
- Apr 22, 2020, 5:44:18 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31507 – Description
initial v1 1 The `QuerySet.exists` method performs optimization by [https://github.com/django/django/blob/67f9d076cfc1858b94f9ed6d1a5ce2327dcc8d0d/django/db/models/sql/compiler.py#L1107-L1115 clearing the select clause], [https://github.com/django/django/blob/67f9d076cfc1858b94f9ed6d1a5ce2327dcc8d0d/django/db/models/sql/query.py#L523-L535 dropping ordering, and limit the number of results to 1 if possible].1 The `QuerySet.exists` method performs optimization by [https://github.com/django/django/blob/67f9d076cfc1858b94f9ed6d1a5ce2327dcc8d0d/django/db/models/sql/compiler.py#L1107-L1115 clearing the select clause], [https://github.com/django/django/blob/67f9d076cfc1858b94f9ed6d1a5ce2327dcc8d0d/django/db/models/sql/query.py#L523-L535 dropping ordering, and limiting the number of results to 1 if possible]. 2 2 3 3 A similar optimization can be applied for combined queries when using `QuerySet.union()` as some query planers (e.g. MySQL) are not smart enough to prune changes down into combined queries. … … 12 12 13 13 {{{#!sql 14 SELECT 1 FROM (SELECT 1 FROM authors WHERE ... LIMIT 1 ...UNION SELECT 1 FROM authors WHERE ... LIMIT 1) LIMIT 1;14 SELECT 1 FROM (SELECT 1 FROM authors WHERE ... LIMIT 1 UNION SELECT 1 FROM authors WHERE ... LIMIT 1) LIMIT 1; 15 15 }}} 16 16