# Timeout Status Records

> Unknown status in the health records.

Canonical URL: <https://datadriven.io/problems/timeout_status_records>

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

During an incident investigation, you suspect some service health records have a timeout status. Find all rows with that status value and return all available fields for each matching row.

## Worked solution and explanation

### What this is really asking

`svc_health.status` is a free-text column and `'timeout'` is one of the values on-call writes when a probe fails to respond. The job is to surface every such row across 20M records for the incident review.

---

### Break down the requirements

#### Step 1: Filter on the literal

`WHERE status = 'timeout'`. The prompt names the value exactly, so an exact equality match is right.

#### Step 2: Return every column

`SELECT *` is the right call here. The prompt says all available fields; naming them risks drift if the schema gains a column.

---

### The solution

**EXACT-MATCH FILTER**

```sql
SELECT *
FROM svc_health
WHERE status = 'timeout'
```

> **Cost Analysis**
>
> 20M rows partitioned by `checked`, but the filter is on `status`, so partition pruning contributes nothing. Full scan. An index on `status` would help, but for a low-cardinality enum the planner often prefers the scan anyway. At incident time, scope by `checked >= ...` to prune.

> **Interviewers Watch For**
>
> Whether you ask about case sensitivity. `'timeout'` versus `'Timeout'` versus `'TIMEOUT'` are different strings in Postgres and most engines. If `status` is free-text, `LOWER(status) = 'timeout'` is the defensive form.

> **Common Pitfall**
>
> Reaching for `status LIKE '%timeout%'` to be flexible. That matches `'connection-timeout'` and `'timeout-after-retry'` too. The prompt asks for the exact status value, so use equality.

> **The False Start**
>
> First instinct is `SELECT check_id, svc_name, status, latency, uptime, checked, region FROM svc_health WHERE ...`, listing every column. Works today, breaks the moment the table grows a column. Pivot to `SELECT *`: the prompt says all fields, and `*` keeps the query future-proof.

---

### COMMON FOLLOW-UP QUESTIONS

## Common follow-up questions

- Restrict the result to the past hour for an active incident page. _(Adds `AND checked >= datetime('now', '-1 hour')`, which prunes partitions and tightens the scan to one shard.)_
- Return one row per service, summarizing how many timeouts each has had. _(Switches from row dump to `SELECT svc_name, COUNT(*) FROM svc_health WHERE status = 'timeout' GROUP BY svc_name`.)_
- What if `status` values mix casing across services? _(Wrap in `LOWER(status) = 'timeout'` and consider whether to add a CHECK constraint or a normalization step upstream.)_

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/timeout_status_records)
- [SQL Interview Questions](https://datadriven.io/sql-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.