Assume I have 5 stores in 5 different cities. I want to find out how much I earned per day per city for this month.
I have 2 options.
1) Logic on the App server:
for (each city)
for (each day) {
Query(city, day);
}
}
This would result in city * day queries.
2) Logic on DB server: Add a single complicated aggregation query.
Which of the two options is preferred? Looking for pros and cons of both ? Which one appears more readable?