News for hackers. Stuff that matters.
Re:My £4 a month server can handle 4.2M requests a day by simonw on Tuesday September 07, 2021 @08:35PM (#28451553)
I agree that this stuff can definitely be handled better.

https://github.com/django-query-profiler/django-query-profil... has a neat option for detecting likely N+1 queries. I usually use the Django Debug Toolbar for this.

Django's ".only()" method lets you specify just the columns you want to retrieve - with the downside that any additional property access can trigger another SQL query. I thought I'd seen code somewhere that can turn those into errors but I'm failing to dig it up again now.

I've used the assertNumQueries() assertion in tests to guard against future changes that accidentally increase the number of queries being made without me intending that.

The points you raise are valid, but there are various levels of mitigations for them. Always room for improvement though!

Re:My £4 a month server can handle 4.2M requests a day by benhoyt on Tuesday September 07, 2021 @08:41PM (#28451591)
Thanks for the thoughtful responses and the link -- Django Query Profiler looks nice!