#21484 closed Bug (fixed)
Document that SQL logging does not include "framework level" queries
Reported by: | Brian May | 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 |
Description
As discussed here https://docs.djangoproject.com/en/dev/topics/logging/ 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 NAMES utf8 set autocommit=0 SET SQL_AUTO_IS_NULL = 0 set autocommit=1 set autocommit=0 rollback 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.
Thanks
Attachments (1)
Change History (6)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Component: | Database layer (models, ORM) → Documentation |
---|---|
Triage Stage: | Unreviewed → 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 by , 11 years ago
Has patch: | set |
---|---|
Summary: | sql logging incomplete → Document that SQL logging does not include "framework level" queries |
by , 11 years ago
Attachment: | 21484.diff added |
---|
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.