Debug Mode Overview
Debug mode outputs:- Generated SQL — Exact query sent to PostgreSQL
- Execution time — Query duration in milliseconds
- Row count — Number of rows returned
- Entity name — Which entity was queried
Debug mode only affects query visibility — it does NOT change query execution or results.
Enabling Debug Mode
Add.Debug() to any query chain:
Debug Output Examples
Simple Query
Query with Filters
Query with Relations (Eager Loading)
Query with Field Projection
Debugging Mutations
Debug mode also works with Insert, Update, and Delete operations:Insert with Debug
Update with Debug
Delete with Debug
Performance Troubleshooting
Identifying Slow Queries
Use Debug mode to find performance bottlenecks:Checking Generated SQL
Verify that ChameleonDB generates efficient SQL:Good signs:
- WHERE clauses are combined with AND
- Only requested fields are selected
- No unnecessary JOINs
Analyzing N+1 Query Problems
Debug mode helps identify N+1 query issues:Debugging Common Issues
No Rows Returned
Filter Not Working
Check the generated SQL to verify filter logic:Relation Not Loading
CLI Debugging Commands
Verify Schema Integrity
Check for vault tampering:Check Migration Status
See if migrations are pending:View Version History
Debug schema evolution:Validate Schema
Check for syntax errors:Debug Mode Best Practices
Use Debug during development
Use Debug during development
Enable Debug mode for all queries during active development:
Remove Debug in production
Remove Debug in production
Debug output adds overhead — remove before deploying:
Check execution times
Check execution times
Use TRACE output to identify slow queries:
Verify eager loading
Verify eager loading
Ensure Include() generates efficient SQL:
Compare with EXPLAIN ANALYZE
Compare with EXPLAIN ANALYZE
Use PostgreSQL’s EXPLAIN for deeper analysis:
Troubleshooting Checklist
Query Returns No Results
1
Enable Debug mode
2
Check generated SQL
Verify the WHERE clause is correct:
3
Run SQL directly in database
4
Check for typos in entity/field names
Slow Query Performance
1
Enable Debug to measure time
2
Identify slow operations
3
Add database indexes
4
Use field projection
Only select needed fields:
Migration Fails
1
Check mode restrictions
2
Verify integrity
3
Check DATABASE_URL
4
View detailed error
Next Steps
Query Guide
Learn advanced query patterns
Migration Workflow
Master the migration system
Performance
Optimize query performance
Architecture
Understand system internals