# Compute Nodes in Key Regions

> Compute nodes across the key regions.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

The infrastructure team is auditing compute capacity in the primary US and EU regions. List all nodes classified as 'compute' in either 'us-east-1' or 'eu-west-1'.

## Worked solution and explanation

### Why this problem exists in real interviews

This is a basic multi-condition WHERE filter. It verifies that you can combine equality checks with IN clauses for set membership.

---

### Break down the requirements

#### Step 1: Filter by node type and region

`WHERE node_type = 'compute' AND region IN ('us-east-1', 'eu-west-1')` matches the two target regions.

#### Step 2: Return all columns

`SELECT *` returns the full node record as implied by the prompt.

---

### The solution

**Multi-condition filter with IN clause**

```sql
SELECT *
FROM infra_nodes
WHERE node_type = 'compute'
  AND region IN ('us-east-1', 'eu-west-1')
```

> **Cost Analysis**
>
> Scan of 8K rows. Trivially fast. A composite index on `(node_type, region)` would help at larger scales.

> **Interviewers Watch For**
>
> Whether you use `IN ('us-east-1', 'eu-west-1')` vs two OR conditions. Both are correct, but IN is cleaner for set membership.

> **Common Pitfall**
>
> Forgetting one of the two regions or using AND instead of IN/OR would produce incorrect results. Read the prompt carefully for the exact region names.

---

## Common follow-up questions

- What if you needed all node types, not just compute? _(Remove the node_type filter; tests whether you over-filter.)_
- How would you count nodes per region instead of listing them? _(Replace SELECT * with GROUP BY region, COUNT(*).)_
- What if the region list were dynamic? _(Tests parameterized queries or subquery-based IN clauses.)_

## Related

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