# Overloaded Infrastructure Nodes

> CPU above 90. Memory above 80. Red alert.

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

Domain: SQL · Difficulty: medium · Seniority: L3

## Problem

A node is considered overloaded if its CPU exceeds 90% or its memory exceeds 85%. Surface each unique overloaded node's hostname, region, and node type.

## Worked solution and explanation

### Why this problem exists in real interviews

Querying infra_nodes for hostname data using query construction tests whether you can translate a business requirement into the right column references and filter sequence. It shows up in mid-level screens to verify practical fluency.

---

### Break down the requirements

#### Step 1: Apply threshold conditions

`WHERE cpu_pct > 90 OR mem_pct > 85` identifies overloaded nodes by either metric.

#### Step 2: Deduplicate

`SELECT DISTINCT hostname, region, node_type` ensures each node appears once even if multiple readings exceed thresholds.

---

### The solution

**OR threshold with DISTINCT**

```sql
SELECT DISTINCT hostname, region, node_type
FROM infra_nodes
WHERE cpu_pct > 90 OR mem_pct > 85
```

> **Cost Analysis**
>
> With `infra_nodes` (10,000 rows), this query scans a small dataset. No indexing is needed for this volume. At production scale, an index on the primary filter column would improve performance.

> **Interviewers Watch For**
>
> Interviewers evaluate whether you translate the English requirements into the correct SQL clauses on the first attempt. They watch for clean syntax, correct column references, and whether you verify edge cases before declaring the query complete.

> **Common Pitfall**
>
> The most common mistake is misreading the prompt's filtering or grouping requirements. Double-check which columns to group by, which to aggregate, and whether the output should be filtered with `WHERE` (before grouping) or `HAVING` (after grouping).

---

## Common follow-up questions

- If infra_nodes.node_id could contain unexpected NULL values, how would your query behave? _(Tests NULL awareness even when the schema does not currently allow NULLs in node_id.)_
- How would you verify that your aggregation on infra_nodes.node_id is not double-counting due to duplicate rows? _(Tests data quality awareness and deduplication strategies.)_
- What index would you add to infra_nodes to avoid a full table scan when filtering or sorting by node_id? _(Tests practical indexing decisions for numeric filter columns.)_

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/overloaded_infrastructure_nodes)
- [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.