Query Exercise: Find the Best Time for Maintenance


If we’ve gotta take the database down for maintenance – perhaps a version upgrade, perhaps upgrading our own code, maybe scaling up the hardware – when’s the best time to do it?

For this week’s query exercise, the business has asked us to identify 3 1-hour periods with the least user activity, in this format:

Mondays, 1:00-1:59 Saturdays, 23:00-23:59 Sundays, 2:00-2:59

Pop open the Stack Overflow database, and for the sake of simplicity for this exercise:

We’re just going to look at the users table. We’ll judge load by times when the fewest number of users are