3 ms·
I'm convinced that this is due to developers over-relying on ORMs instead of delving into raw SQL. I'll give another, different but somewhat related example: c
by solatic 3y ago
I'm convinced that this is due to developers over-relying on ORMs instead of delving into raw SQL.
I'll give another, different but somewhat related example: consider a worker that works on a batch of rows, and wants to update each of the rows in the batch, each row with different data for that row. In raw SQL, this is simple enough with the UPDATE FROM VALUES pattern (see e.g. https://stackoverflow.com/a/18799497 https://stackoverflow.com/a/18799497 ).
There's no support for this in Prisma, for example: https://www.prisma.io/docs/orm/prisma-client/queries/crud#update-multiple-records https://www.prisma.io/docs/orm/prisma-client/queries/crud#up... . Most developers would wrap prisma.foo.update in an application-level loop, or possibly wrap all the individual updates in a single prisma.$transaction.
- sgarland 3y agoI think maybe with Django, you could use a QuerySet with an F expression to do this? [0] Agreed that it's trivial in pure SQL. As a counter though, having worked at places using an ORM (mostly Django), and also where everything was raw SQL, the latter winds up having WILDLY inefficient schema and queries that the DB team (me) has to fix later. I lost any respect for Prisma when I learned it doesn't do JOINs in the DB. [1] [0]: https://docs.djangoproject.com/en/5.0/ref/models/expressions/#f-expressions https://docs.djangoproject.com/en/5.0/ref/models/expressions... [1]: https://github.com/prisma/prisma/issues/5184 https://github.com/prisma/prisma/issues/5184
- solatic 3y ago> raw SQL... winds up having WILDLY inefficient schema and queries that the DB team (me) has to fix later. I won't dispute this, I'll just point out that (a) premature optimization is the root of all evil, (b) because it's raw SQL, it's easier to reason about and fix. Inefficient queries aren't really a problem in the early days when your whole dataset doesn't even add up to a gigabyte.
- sgarland 3y agoThe queries aren't necessarily a problem early on (although I've seen OFFSET/LIMIT used for pagination, which is just... no), but schema is sticky. Terrible decisions made early on only become harder to fix as the data set grows.