Re:12 requests per second: A realistic look at Python web fr...
by Hamuko on Friday February 19, 2021 @06:13AM
(#26191846)
`QuerySet.select_related()` and `QuerySet.prefetch_related()` are the bread and butter of Django query optimisation. I think most of the time that I've noticed a performance issue in our code, it's been easily fixed with one of those.
[ Parent
| on HN ]
Re:12 requests per second: A realistic look at Python web fr...
by rglullis on Friday February 19, 2021 @06:29AM
(#26191969)
Django's ORM gets a lot of flak, but I don't remember the last time I had complex queries that I could not do with
it.
You still need to understand a minimum of SQL and databases, and usually those that complain about the ORM are the ones that expect it to be a "sufficiently advanced compiler", but it has matured so much that nowadays the developers consider a *bug* every time the answer to How do I do this query X? involves something along the lines of use .extra or raw sql.
Re:12 requests per second: A realistic look at Python web fr...
by RussianCow on Friday February 19, 2021 @04:36PM
(#26198328)
This is true, though to be fair to the critics, the syntax through which you express these complex queries is often clunky and unintuitive. For example, I need to re-read the documentation every time I use the annotation API because it's generally not obvious how to use it, and I've run into a few edge cases where you need extra code/syntax just to deal with its nuances and ambiguities.
Even though Django has come a long way, I greatly prefer ORMs like SQLAlchemy and Ecto that map more closely to the SQL query I'm trying to write.