Opened 14 years ago

Closed 14 years ago

#12763 closed (duplicate)

Record matching ORM statement in connection.queries for debugging

Reported by: Daniel Marohn Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: orm debug sql
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Attachments (1)

django_db_debug_query_caller.diff (1.2 KB ) - added by Daniel Marohn 14 years ago.
a simple patch

Download all attachments as: .zip

Change History (2)

by Daniel Marohn, 14 years ago

a simple patch

comment:1 by Karen Tracey, 14 years ago

Resolution: duplicate
Status: newclosed

django-debug-toolbar provides this, and more. We've already got a ticket to track possibly integrating the toolbar into base Django (#11698). I don't believe we want to also consider adding bits piecemeal as well, so I'm going to close this as a dupe of that one.

Note: See TracTickets for help on using tickets.
Back to Top