How would you approach query optimization for high-volume datasets?
For this exercise, write an optimized PostgreSQL query over the supplied tables. Include only active accounts, active usage event types, processed events, and events occurring during January 2026.
event_date, account_id, account_name, event_count, and total_duration_seconds.event_date ascending, then account_id ascending.| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Account identifier |
| account_name | VARCHAR(100) | Account display name |
| account_status | VARCHAR(20) | Current account status |
| Column | Type | Description |
|---|---|---|
| event_type_idPK | INT | Event type identifier |
| event_type_name | VARCHAR(80) | Event type name |
| category | VARCHAR(40) | Event type category |
| is_active | BOOLEAN | Whether the event type is active |
| Column | Type | Description |
|---|---|---|
| event_idPK | BIGINT | Event identifier |
| account_id | INT | Related account identifier |
| event_type_id | INT | Related event type identifier |
| occurred_at | TIMESTAMPTZ | Event timestamp |
| event_status | VARCHAR(20) | Processing status |
| duration_seconds | INT | Event duration in seconds |