News for hackers. Stuff that matters.
Re:How not to structure database-backed web apps: performanc... by mnm1 on Thursday June 28, 2018 @04:04AM (#17414957)
Even if you get 1 hit / day and that takes a long time to return, the ORM has failed your one customer. Inefficiency exists even at small scales with ORMs. If your developers don't know how to write SQL, let them learn. Or fire them if they won't.
Re:How not to structure database-backed web apps: performanc... by olavk on Thursday June 28, 2018 @04:11AM (#17414984)
> Inefficiency exists even at small scales with ORMs

ORMs are not inherently inefficient. And in my time I have seen plenty of n+1 style queries written with raw SQL.

Re:How not to structure database-backed web apps: performanc... by mnm1 on Thursday June 28, 2018 @11:42AM (#17417807)
Lazy loading often fetches too little and eager loading too much. Most orms select all columns in all tables regardless of need. The query translation and hydration overhead of transforming the data into objects even in a fast language are always going to be problems, it's just a matter of how big, over a system without the orm. Since orms are superfluous, every line of code in them adds unnecessary overhead. They are indeed inherently inefficient by definition.
Re:How not to structure database-backed web apps: performanc... by olavk on Thursday June 28, 2018 @01:19PM (#17418773)
> The query translation and hydration overhead of transforming the data into objects even in a fast language are always going to be problems

No they are not. Have you measured this in a real-world application? This overhead is negligible compared to the cost of the query itself. And without an ORM you still have to load the data into some kind of objects or data structures before you pass it to presentation, you will just have to write the code yourself.

But yeah, lazy loading in a loop will kill performance. So don't do that.

Re:How not to structure database-backed web apps: performanc... by NightlyDev on Thursday June 28, 2018 @05:18PM (#17420562)
It's definetly not always going to be a problem, but sometimes it does. ORM is always slower than writing custom code, but it might be more than fast enough.
Re:How not to structure database-backed web apps: performanc... by olavk on Friday June 29, 2018 @05:45AM (#17423490)
Surely it depends on the custom code in question if it is faster or slower than the similar ORM logic?

You may be able to write faster code, but unless you are Donald Knuth, you can't guarantee that any custom code you write will always be faster than some library.

Re:How not to structure database-backed web apps: performanc... by blattimwind on Thursday June 28, 2018 @10:12AM (#17416993)
> Inefficiency exists even at small scales with ORMs.

In other words, you have no idea what you're talking about.

Re:How not to structure database-backed web apps: performanc... by dang on Thursday June 28, 2018 @02:59PM (#17419536)
Personal attacks will get you banned here, regardless of how wrong someone else is. You've unfortunately been uncivil in at least one other comment in this thread too.

Could you please (re-)read https://news.ycombinator.com/newsguidelines.html and not use this site that way? The idea here is to post civilly and substantively, or not at all.

Re:How not to structure database-backed web apps: performanc... by blattimwind on Thursday June 28, 2018 @04:51PM (#17420382)
Ok.
Re:How not to structure database-backed web apps: performanc... by mnm1 on Thursday June 28, 2018 @11:33AM (#17417722)
So the ORM taking many seconds for query overhead isn't a problem? This makes the web page served by this api many seconds slower. A second of slowness increases bounce rate by quite a bit and by two to three seconds, most visitors abandon the website. I guess that doesn't matter to you as you post a comment without substance and only an insult.
Re:How not to structure database-backed web apps: performanc... by falsedan on Thursday June 28, 2018 @11:45AM (#17417852)
I think you have bigger fish to fry than site performance if you're getting 1 hit per day.
Re:How not to structure database-backed web apps: performanc... by mnm1 on Thursday June 28, 2018 @12:30PM (#17418314)
I think you completely missed the point here. If this happens for one customer, it happens for all of them and no amount of hardware thrown at the problem is going to solve this because it's already running on the best hardware available.
Re:How not to structure database-backed web apps: performanc... by olavk on Thursday June 28, 2018 @01:28PM (#17418850)
What ORM setup gives you "many seconds" overhead on a small website? Are you sure the ORM is to blame? I suspect you are doing something like lazy loading in a loop or joining/filtering on the client side.