3 ms·
I've thought about the same problem and think I have an explanation. SQL inherently avoids operations that cannot scale. This means that while the same operatio
by ramraj07 8y ago
I've thought about the same problem and think I have an explanation. SQL inherently avoids operations that cannot scale. This means that while the same operation can be written much more simpler as code if you're doing with pandas or spark, trying to do it with SQL would be less forgiving if your underlying data schema is not optimal or if your logic isn't scalable. But more often than not, the SQL query will run faster and more reliably given similar amounts of compute power to the two engines.
Of course you can always screw up and write suboptimal SQL that will take forever to finish, but it's just harder to do unless you're really trying to be dumb about it.
So I do think there's still a lot of merit in trying to learn and use SQL more.
- sixo 8y agoIt also ignores operations of type (set of rows) => (set of rows) or (row) => (set of rows). and makes you jump through hoops of CTEs to implement them except in some special cases. Limited versions of these (flatMaps) work just fine in spark and have no problems scaling.
- kumarvvr 8y agoI want to learn and do the same things in SQL because, I don't always have the opportunity to run python programs on the database server environment. There are certain situations where an SQL query is all that I can work with.