// advent-of-postgres/day-10
The Maintenance Windows
Two services in maintenance at the same time is how the night shift gets paged. Count the overlapping windows, and know what "touching" means for a range.
The rule is simple: two services should not be in maintenance at the same time. Bushy has the schedule for 10 December and a bad feeling about it.
The schedule is in maintenance:
| Column | Type | Notes |
|---|---|---|
id |
int |
Primary key |
service |
text |
Who is doing maintenance |
window_ |
tstzrange |
[start, end): the end is not included |
A window that ends at 10:00 and another that starts at 10:00 only touch. They do not overlap. Two windows of the same service never count.
Your task
How many pairs of windows from different services overlap? Count each pair once.
Submit the number.
Stuck? Show a hint
&& is the overlap operator for ranges. Join the table to itself and keep each pair once.
Download today's data as SQL to solve it on your own Postgres (14 or later).
Solved this puzzle? Share it.
Tag @thedevopsdaily and share it with the community.
We earn commissions when you shop through the links below.
Bitrise
Managed runners for GitHub Actions
Bitrise Build Hub runs your GitHub Actions jobs on M4 Macs and AMD Linux machines. Change runs-on and keep your workflows, secrets and logs on GitHub.
Atomsized
AWS platform engineering and GitOps
Design and automation for reliable AWS and Kubernetes platforms, safer delivery workflows, and preview and UAT environments your engineers can understand and own.
DigitalOcean
Cloud infrastructure for developers
Simple, reliable cloud computing designed for developers
DevDojo
Developer community & tools
Join a community of developers sharing knowledge and tools
SMTPfast
Developer-first email API
Send transactional and marketing email through a clean REST API. Detailed logs, webhooks, and embeddable signup forms in one dashboard.
QuizAPI
Developer-first quiz platform
Build, generate, and embed quizzes with a powerful REST API. AI-powered question generation and live multiplayer.
Want to support DevOps Daily and reach thousands of developers?
Become a Sponsor