-
Notifications
You must be signed in to change notification settings - Fork 288
Debugging SQL
Allan Nordhøy edited this page Apr 18, 2018
·
2 revisions
You can have Pootle output the SQL calls that are created by sections of code:
from pootle.core.debug import debug_sql
with debug_sql():
trigger_some_sql()
It is worth remembering that Django querysets are evaluated lazily, so you might need to manually trigger the call:
with debug_sql():
[x for x in trigger_some_sql()]
When running Pootle tests you can see a count of the database calls that were made for each test, and some overall test metrics.
py.test -vv --debug-tests mytest.log
This can be used with the -k
flag so you can test a subset of the test suite for db performance.
For example to test performance of update related code
py.test -vv -k update --debug-tests mytest.log
Debugging information for the test run is appended to the specified file. You can watch the debugging with
tail -f mytest.log