Record matching ORM statement in connection.queries for debugging
|Reported by:||camillo||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Severity:||Keywords:||orm debug sql|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
As described in the documentation, when DEBUG is true every query that is executed is recorded in django.db.connection.queries. Currently, the raw SQL and the execution time are recorded. It would be useful if the ORM invocation that triggered the execution of the query were also recorded. This would be particularly helpful with views that trigger a large number of query, especially when you have many similar or identical queries and you are trying to find the best places to use select_related or other optimizations.