4 ms·
Recently I tried using an ORM "properly" for a bigger application. I tried for days to fix the performance problems, which were mainly caused by serialization/d
by thegeomaster 8y ago
Recently I tried using an ORM "properly" for a bigger application. I tried for days to fix the performance problems, which were mainly caused by serialization/deserialization overhead because of humongous generated queries where I didn't need 90% of the info.
I finally gave up, and now most of the ORM usage in the codebase is just to communicate my custom queries to the underlying database and translate to/from domain entities. I feel like this is the sweet spot―give me a thin abstraction over SQL and do the gruntwork of converting domain entities to tables and vice-versa, but nothing else, thanks.
I'm still unhappy about the performance (when everything is in the working set, query takes 2ms and returns a couple of rows but the whole API call, which doesn't do much except massage the response to some kind of JSON, takes 30ms!), but that's on me for my ORM/language/runtime choice, I suppose.
- lugg 8y agoWhat language are you using? Most languages plain sql drivers have something like a cast result row into object as you cursor over the set. E.g. PHP has fetchObject https://www.php.net/manual/en/pdostatement.fetchobject.php https://www.php.net/manual/en/pdostatement.fetchobject.php
- ak39 8y ago"I feel like this is the sweet spot―give me a thin abstraction over SQL and do the gruntwork of converting domain entities to tables and vice-versa, but nothing else, thanks." Something like iBatis/nBatis? (Haven't used this since 2004)
- lukaseder 8y agojOOQ!
- coleifer 8y agojOOQ is legit. I found it very helpful to read jOOQ as I was writing my own library in python. There's a huge difference between a query-builder and something like hibernate or sqlalchemy. Query-builders make it easy to compose queries, leaning on your programming language to enforce syntactic correctness. When you're dealing with SQL directly, composition means string concatenation. A query builder gives you a data-structure that represents a query. I think it's helpful to distinguish between query-building and object mapping when the "orm-vs-sql" thing comes up.
- michaelcampbell 8y ago*Batis is still a thing, and is closer to what they were asking for, but you're still mapping your domain to hand-coded SQL. That's not bad, necessarily; I just don't know if his "abstraction over SQL" means you write it and your domain code uses that abstraction, or it's provided by the framework.
- balfirevic 8y ago> Recently I tried using an ORM "properly" Which ORM was it, if I may ask?
- michaelcampbell 8y ago> Recently I tried using an ORM "properly" No, you weren't. > ...queries where I didn't need 90% of the info.