Re:How I Reduced My DB Server Load by 80%
by jaggederest on Tuesday October 10, 2017 @03:57AM
(#15440103)
The best of both worlds is just to... actually understand the ORM you choose to use.
I'm always confused by how reluctant folks are, in general, to read underlying libraries.
Re:How I Reduced My DB Server Load by 80%
by Can_Not on Tuesday October 10, 2017 @02:27PM
(#15444137)
You don't even have to read the library source, just verify the SQL statements generated. Most ORMs let you drop into raw SQL for advanced clauses and sub-statements. For me there value of an ORM is composable business logic. For example, if whereHasLotsOfTrees is a complicated SQL subquery and has it's business logic definition changed, I can edit only one function and have the new logic work everywhere.
There is always a trade-off. The code you wrote, even if it is poorly re-implentation, you know it inside out, since you wrote it. The third party code, may be better, but people usually make a lot of implicit assumptions and end up not using it correctly, so you end up in situations like this.
For DB layer, I usually prefer custom code so I know exactly what is going on under the hood.