# All Infra Regions

> The infrastructure spans the globe. Map it.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

Before provisioning a new availability zone, the infrastructure team needs to know which regions already have node presence. Pull a deduplicated list of every region currently represented in the node inventory.

## Worked solution and explanation

### Why this problem exists in real interviews

Working with `infra_nodes`, this problem isolates filtering and projection. The interviewer expects candidates to articulate why `hostname`, `region`, `node_type` matter for correctness before touching the keyboard.

---

### Break down the requirements

#### Step 1: Filter `infra_nodes` to qualifying rows

Apply the WHERE clause to keep only rows matching the prompt criteria. This reduces the working set before deduplication.

#### Step 2: Deduplicate with DISTINCT

`SELECT DISTINCT region` removes duplicate values, producing one row per unique entry.

#### Step 3: Sort the output

Order by `region` for deterministic, readable results.

---

### The solution

**Distinct-filter for infra regions**

```sql
SELECT DISTINCT region
FROM infra_nodes
ORDER BY region
```

> **Cost Analysis**
>
> The main table has 2K rows.

> **Interviewers Watch For**
>
> Clean, readable SQL with correct column references signals production readiness. Candidates who verbalize their approach before coding score higher on communication.

> **Common Pitfall**
>
> Returning extra columns not asked for, or missing a required column, are both common mistakes that fail automated grading.

---

## Common follow-up questions

- What happens to your results if `hostname` in `infra_nodes` contains trailing whitespace or mixed casing? _(Tests awareness of text normalization issues that silently fragment GROUP BY results.)_
- If `infra_nodes` were partitioned by date, would your query need to scan all partitions or could it prune? How would you verify? _(Tests understanding of partition pruning and EXPLAIN output.)_
- The `region` column in `infra_nodes` has a zipf distribution, meaning a few values dominate. How does that skew affect your query plan and parallelism? _(Tests understanding of data skew: the optimizer may choose a bad plan when histogram statistics are stale.)_
- Could you express this same logic as a single query without CTEs or subqueries? What readability trade-off does that introduce? _(Tests whether the candidate can flatten nested logic and understands when decomposition aids maintainability.)_

## Related

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