Write a query to optimize a slow-performing database join on a table containing millions of sensor telemetry logs.
Use the provided PostgreSQL tables and restrict analysis to January 2026. Return only active sensors that have telemetry during that period.
sensor_id, site_code, sensor_name, latest_recorded_at, latest_temperature_c, previous_temperature_c, and temperature_delta_clog_idsensor_id ascending| Column | Type | Description |
|---|---|---|
| sensor_idPK | INTEGER | Unique sensor identifier |
| site_code | VARCHAR(20) | Site identifier assigned to the sensor |
| sensor_name | VARCHAR(100) | Human-readable sensor name |
| is_active | BOOLEAN | Whether the sensor is currently active |
| Column | Type | Description |
|---|---|---|
| log_idPK | BIGINT | Unique telemetry log identifier |
| sensor_id | INTEGER | Sensor that produced the reading |
| recorded_at | TIMESTAMP | Timestamp when the reading was recorded |
| temperature_c | NUMERIC(6,2) | Temperature reading in degrees Celsius |
| status | VARCHAR(20) | Telemetry processing status |