3 ms·
Every horror you've just described can happen up in the app layer as well. The problem is SQL is not a programming language and the only way to accomp
by JohnBooty 7y ago
Every horror you've just described can happen up in the app layer as well.
The problem is SQL is not a programming language and the only way to
accomplish some things directly in the database is by creating solutions
with O(n^2) or worse running-time. Our system has queries with O(n^4)
time complexity.
Two observations here.
1. The approach being espoused is not, "Move everything down into the database layer at all costs, no exceptions." It's more like, "Many things are simpler and faster at the database layer."
2. These O(n^2) (and n^3, n^4, whatever) horrors are at least as common at the app layer. I have dealt with my fair share at every possible level of the stack.
I had to untangle a query that was over 3,100 lines long with 18 sub-queries
I just want to say: ouch. I am sorry!
- yonixw 7y agoYou say "could happen" he says "must happen". SQL won't be able to lower the complexity needed. But in the app level it is just a matter of being good programmer or under good review process.