3 ms·
Self plug: Checkout https://github.com/har777/pellet https://github.com/har777/pellet to easily find and fix django N+1 issues. I usually add it to existing in
by har777 4y ago
Self plug: Checkout https://github.com/har777/pellet https://github.com/har777/pellet to easily find and fix django N+1 issues.
I usually add it to existing integration tests so that they raise exceptions on N+1. If test coverage is low then I would suggest sending the N+1 metrics to something like datadog. That way your users using the product will reveal all the N+1 issues on your monitoring solution.
EDIT: I should add a screenshot to the README lol but the middleware will print each api being called with a nice table showing each query and the number of times it was called for the api.
- stavros 4y agoThis is great! I also use https://pypi.org/project/django-zen-queries/ https://pypi.org/project/django-zen-queries/, but Pellet might be better (Zen queries doesn't let you run any queries, which sometimes doesn't work). Here's a screenshot for you: https://imgz.org/i8XkiK2R.png https://imgz.org/i8XkiK2R.png
- har777 4y agoYay! And thanks for the screenshot :D