1👍
One option is to use django-debug-toolbar: it measures every query done on every view.
It is a must on any django app.
Regarding the other questions:
-
I would say they are equivalent. In Django code,
get
usesfilter
and retrieves the first element. -
should also be equivalent because
filter
andexclude
are just different names forfilter(Q(...))
andfilter(~Q())
and chaining is equivalent to have a comma: the queries are connected with byAND
.
However, because in one you are using"open"
and in the other"close"
, this can have an impact in how the particular backend will perform, and AFAIK this difference can only be measured by profiling.
Source:stackexchange.com