Opened 5 months ago

Closed 4 months ago

Last modified 4 months ago

#21484 closed Bug (fixed)

Document that SQL logging does not include "framework level" queries

Reported by: brian Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


As discussed here django supports logging of raw SQL queries. "For example, every SQL statement executed by a request is logged at the DEBUG level to this logger."

However, at least for mysql, this doesn't include initialization or session management SQL queries.

Using wireshark I see a number of extra queries, that are never logged, like:

set autocommit=0
set autocommit=1
set autocommit=0
set autocommit=1

I assume "commit" is also on this list, however not part of this test.

Being able to see all the queries is important in order to debug obscure problems.


Attachments (1)

21484.diff (1.2 KB) - added by timo 4 months ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I think for most use cases this would just add more noise to the logs. You can always turn on query logging at the database level if you need it. I'll leave this open for a second opinion and perhaps we can make a documentation update to note this limitation if we don't change the behavior.

comment:2 Changed 5 months ago by aaugustin

  • Component changed from Database layer (models, ORM) to Documentation
  • Triage Stage changed from Unreviewed to Accepted

In my opinion, the SQL logger aims at providing "application-level" debugging. It answers the question "what queries does my application emit?". The queries you're mentionning are "framework-level". If your question is "what queries does my database receive?", like Tim, I suggest turning on the database's query logging.

comment:3 Changed 4 months ago by timo

  • Has patch set
  • Summary changed from sql logging incomplete to Document that SQL logging does not include "framework level" queries

Changed 4 months ago by timo

comment:4 Changed 4 months ago by Tim Graham <timograham@…>

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

In 4d8d76e7a89858932b6f4f280a0ebf4cf94ab4b7:

Fixed #21484 -- Documented that SQL logging does not include "framework level" queries.

comment:5 Changed 4 months ago by Tim Graham <timograham@…>

In a228545026e30d3223b3fbb13a262b5e005101ae:

[1.6.x] Fixed #21484 -- Documented that SQL logging does not include "framework level" queries.

Backport of 4d8d76e7a8 from master

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.