You don't solve the N+1 problem by eliminating for loops and recursions.
You solve N+1 problem by training and teaching SQL operators to think in sets and graphs instead of algos and data structures.
Programmers trained to think in algos and data structures will simply fallback to language that has loops and recursions (some ORM probably).
Yes, procedural extensions of SQL do have those things. Because they are, well, procedural extensions. That doesn't mean that loops and recursions aren't anti patterns in SQL or set based arithmetic and thinking. That they are.
But that doesn't mean they don't have a legit case in database programming. They do. Cursors come to mind for loops, rare but sometimes needed, or formula expression parser that works on a row level for recursions. Rarely needed, but it happened to me once. Although graph processing did require a lot of recursion but with introduction of the new graph langaugue features it becomes obsolote.
6
u/vbilopav89 7d ago
You don't solve the N+1 problem by eliminating for loops and recursions.
You solve N+1 problem by training and teaching SQL operators to think in sets and graphs instead of algos and data structures.
Programmers trained to think in algos and data structures will simply fallback to language that has loops and recursions (some ORM probably).
Yes, procedural extensions of SQL do have those things. Because they are, well, procedural extensions. That doesn't mean that loops and recursions aren't anti patterns in SQL or set based arithmetic and thinking. That they are.
But that doesn't mean they don't have a legit case in database programming. They do. Cursors come to mind for loops, rare but sometimes needed, or formula expression parser that works on a row level for recursions. Rarely needed, but it happened to me once. Although graph processing did require a lot of recursion but with introduction of the new graph langaugue features it becomes obsolote.
Hope this helps.