MCPcopy
hub / github.com/tortoise/tortoise-orm / explain

Method explain

tortoise/queryset.py:1045–1064  ·  view source on GitHub ↗

Fetch and return information about the query execution plan. This is done by executing an ``EXPLAIN`` query whose exact prefix depends on the database backend, as documented below. - PostgreSQL: ``EXPLAIN (FORMAT JSON, VERBOSE) ...`` - SQLite: ``EXPLAIN QUERY PLAN .

(self)

Source from the content-addressed store, hash-verified

1043 return queryset
1044
1045 async def explain(self) -> Any:
1046 """Fetch and return information about the query execution plan.
1047
1048 This is done by executing an ``EXPLAIN`` query whose exact prefix depends
1049 on the database backend, as documented below.
1050
1051 - PostgreSQL: ``EXPLAIN (FORMAT JSON, VERBOSE) ...``
1052 - SQLite: ``EXPLAIN QUERY PLAN ...``
1053 - MySQL: ``EXPLAIN FORMAT=JSON ...``
1054
1055 .. note::
1056 This is only meant to be used in an interactive environment for debugging
1057 and query optimization.
1058 **The output format may (and will) vary greatly depending on the database backend.**
1059 """
1060 self._choose_db_if_not_chosen()
1061 self._make_query()
1062 return await self._db.executor_class(model=self.model, db=self._db).execute_explain(
1063 self.query.get_sql()
1064 )
1065
1066 def using_db(self, _db: BaseDBAsyncClient | None) -> QuerySet[MODEL]:
1067 """

Callers 1

test_explainFunction · 0.80

Calls 4

_make_queryMethod · 0.95
execute_explainMethod · 0.45
get_sqlMethod · 0.45

Tested by 1

test_explainFunction · 0.64