2 ms·
I encountered this a few times and started adding tests that assert each handler only executes the expected number of queries (and no more). If the application
by grw_ 6y ago
I encountered this a few times and started adding tests that assert each handler only executes the expected number of queries (and no more). If the application code is modified such that this N+1 query pattern occurs the test will immediately fail and you go optimise the query, problem solved.
https://docs.djangoproject.com/en/dev/topics/testing/tools/#django.test.TransactionTestCase.assertNumQueries https://docs.djangoproject.com/en/dev/topics/testing/tools/#...
- drunkpotato 6y agoOr the person who changed the code then disables the test or sets N to 100,000,000 or something equally pleasurable to debug.