Hacker News new | ask | show | jobs
by grw_ 1944 days 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/#...

1 comments

Or the person who changed the code then disables the test or sets N to 100,000,000 or something equally pleasurable to debug.