Post #4018572
2026-07-22 11:46 UTC
something that's been surprising about Django is that I always heard that if my Python app is slow, it's probably a bad database query. But so far my experience has been that a lot of the time something in my Python code (either in my own code or in Django or a combination) is using too much CPU, and it's useful to do a CPU profile with py-spy to figure out what's going on and fix it
https://github.com/benfred/py-spy
(3/?)
Replies (2)
-
@JustinAzoff@infosec.exchange 2026-07-22 20:23
@b0rk@social.jvns.ca yeah as other people have mentioned, it isn't usually one bad query that's the problem, it's lots of little ones caused by the ORM (the n+1 issue, or even worse when it's 1+n*m). With sqlite many small queries are still fast and you can get away with a lot of things that would be a major problem with a separate database server, especially if the network is involved.
-
@imclaren@infosec.exchange 2026-07-23 02:50
@b0rk@social.jvns.ca also relative to go, python code does just run materially slower.