Your question is Diagnose Holiday Latency Spikes. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
You are given database telemetry for a customer’s Blue Yonder environment during a holiday peak window. Write a PostgreSQL query that returns the hourly periods where database latency spiked sharply, along with the workload and infrastructure signals most likely associated with the spike. Your result should compare each hour to the previous hour, flag the spike hours, and include the database, hour, latency, query volume, CPU, and active connections.
| Column | Type | Description |
|---|---|---|
| metric_idPK | INT | Primary key for the hourly metric row |
| database_name | VARCHAR(100) | Name of the customer database |
| metric_hour | TIMESTAMP | Hourly timestamp for the metric snapshot |
| avg_latency_ms | NUMERIC(10,2) | Average database latency in milliseconds |
| query_count | INT | Number of queries processed in the hour |
| active_connections | INT | Active database connections during the hour |
| cpu_utilization_pct | NUMERIC(5,2) | CPU utilization percentage for the hour |
| Column | Type | Description |
|---|---|---|
| calendar_datePK | DATE | Holiday date |
| holiday_name | VARCHAR(100) | Holiday or peak-period label |
| is_peak_hour | BOOLEAN | Whether the date belongs to the peak holiday window |