I have a database with 140 million records containing financial transactions. When I do a query to calculate the sum of those records spanning a number of months it takes around 4 seconds on my database server which seems reasonable. However if I run the same query on an application server it takes around 40 seconds to do the same query.
In just this instance I would like to run that piece of code on the database server instead of the application server. It's a query that is only run a few times a day so I would prefer to have a fast result and don't mind putting a bit more stress on my database server for that.