mirror of
https://github.com/django/django.git
synced 2025-11-29 06:51:10 +00:00
Fixed #28574 -- Added QuerySet.explain().
This commit is contained in:
parent
df90e462d9
commit
c1c163b427
15 changed files with 253 additions and 0 deletions
|
|
@ -223,6 +223,10 @@ class Query:
|
|||
|
||||
self._filtered_relations = {}
|
||||
|
||||
self.explain_query = False
|
||||
self.explain_format = None
|
||||
self.explain_options = {}
|
||||
|
||||
@property
|
||||
def extra(self):
|
||||
if self._extra is None:
|
||||
|
|
@ -511,6 +515,14 @@ class Query:
|
|||
compiler = q.get_compiler(using=using)
|
||||
return compiler.has_results()
|
||||
|
||||
def explain(self, using, format=None, **options):
|
||||
q = self.clone()
|
||||
q.explain_query = True
|
||||
q.explain_format = format
|
||||
q.explain_options = options
|
||||
compiler = q.get_compiler(using=using)
|
||||
return '\n'.join(compiler.explain_query())
|
||||
|
||||
def combine(self, rhs, connector):
|
||||
"""
|
||||
Merge the 'rhs' query into the current one (with any 'rhs' effects
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue