Tracking SQL queries for a request
For a typical Django application, database interactions are of key importance. Ensuring that the database queries being made are correct helps to ensure that the application results are correct. Further, ensuring that the database queries produced for the application are efficient helps to make sure that the application will be able to support the desired number of concurrent users.
Django provides support in this area by making the database query history available for examination. Chapter 6, Django Debugging Overview, introduced this history and showed how it could be accessed from a Python shell session. This type of access is useful to see the SQL that is issued as a result of calling a particular model method. However, it is not helpful in learning about the bigger picture of what SQL queries are made during the processing of a particular request.
This section will show how to include information about the SQL queries needed for production of a page in...