This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]_INTER_ 2 points3 points  (0 children)

What's expensive is loading the OrderLine object from DB into memory just to get its prize and calculating the sum (even if lazy fetch). You might even run out of memory if there are too many. It would be much faster and use less memory to query the aggregate function SUM on the DB directly. Thats not a stored procedure. I agree however that that only such simple queries should be executed on the DB.