3 ms·
The example you gave makes no sense. It would be better expressed as a join. There may be examples where it makes sense, but I can't think of any. In SQL Server
by intrasight 6y ago
The example you gave makes no sense. It would be better expressed as a join. There may be examples where it makes sense, but I can't think of any. In SQL Server, I think of a stored proc as a logical operation that takes action and returns one object. If I want sub-structure within that object, I have the stored proc return one json or xml object.
- drdec 6y agoThe example given allows the application layer to instantiate a customer object with a list of order objects in one database query. Yes, you could do that by returning JSON or XML, but why have the extra step of parsing the text? Directly accessing the result set and acting on the object instances will be more efficient.
- intrasight 6y agoThe example is better expressed as a join.
- wayneftw 6y agoNo it's not. A join means you have to wastefully repeat the same parent fields for every row. That's wasted cycles serializing and deserializing and it's more work on the client. It's absolutely ridiculous to make a blanket statement about this very useful feature. I've done the benchmarking on many applications of this tactic. It very often works better with multiple select statements. I'll certainly trust hard performance numbers against an ill conceived opinion any day.