The first version of an app I worked from was very SQL heavy. Almost every calculation was done in a stored proc and the app servers just formatted that.
As the product got popular this became the bottleneck. It's far easier to get more app servers than DB servers.
So we restructured it to do straight index reads and aggregations in the DB, but more complex calculations in the app itself.
It all depends on the circumstances, but I'd still advocate pushing as much in to the DB as you can without making convoluted SQL - your average RDBMS has amazing optimisations for aggregation, sorting and filtering.
But the problem with doing it on the app is that when you are joining huge rows, all of this unfiltered data gets sent over a relatively slow 100-1000 mbit port.
The first version of an app I worked from was very SQL heavy. Almost every calculation was done in a stored proc and the app servers just formatted that.
As the product got popular this became the bottleneck. It's far easier to get more app servers than DB servers.
So we restructured it to do straight index reads and aggregations in the DB, but more complex calculations in the app itself.
It all depends on the circumstances, but I'd still advocate pushing as much in to the DB as you can without making convoluted SQL - your average RDBMS has amazing optimisations for aggregation, sorting and filtering.