SQL Debugging Guide
Overview
Quick Start
# Enable SQL query logging
SQL_DEBUG=True
# Set slow query threshold (in seconds, default 0.01 = 10ms)
SQL_MIN_DURATION=0.01
# Optional: Enable EXPLAIN ANALYZE (executes queries!)
SQL_EXPLAIN_ANALYZE=FalseConfiguration Options
Environment Variables
Variable
Default
Description
Log Files
Common Use Cases
1. Finding N+1 Query Problems
2. Identifying Slow Queries
3. Analyzing Query Plans
4. Query Performance Comparison
5. Debugging Specific Views
Understanding the Log Format
sql.log Format
slow_sql.log Format
Best Practices
Troubleshooting
Logs Directory Not Created
Empty Log Files
EXPLAIN Errors
Performance Impact
Advanced Configuration
Custom Slow Query Threshold per View
Analyzing Log Files
Implementation Details
Last updated