Code

Opened 4 years ago

Closed 4 years ago

#12763 closed (duplicate)

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
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 camillo 4 years ago.
a simple patch

Download all attachments as: .zip

Change History (2)

Changed 4 years ago by camillo

a simple patch

comment:1 Changed 4 years ago by kmtracey

  • Resolution set to duplicate
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.