# US-East KV Store Entries

> KV store inventory. us-east-1.

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

Domain: SQL · Difficulty: easy · Seniority: L3

## Problem

Pull every KV store entry in the us-east-1 region. For each entry, return the entry ID, key, value, TTL in seconds, region, creation time, and expiration time.

## Worked solution and explanation

### Why this problem exists in real interviews

This is a basic single-table filter. Interviewers use it to verify that you can write a clean `WHERE` clause and select all requested columns.

---

### Break down the requirements

#### Step 1: Filter to us-east-1 region

`WHERE region = 'us-east-1'` restricts the 20M row table to entries in the target region.

#### Step 2: Select all requested columns

Return `entry_id`, `kv_key`, `kv_value`, `ttl_secs`, `region`, `created`, and `expires`.

---

### The solution

**Single-predicate filter on region**

```sql
SELECT entry_id, kv_key, kv_value, ttl_secs, region, created, expires
FROM kv_store
WHERE region = 'us-east-1'
```

> **Cost Analysis**
>
> With 6 regions, the filter reduces 20M rows to ~3.3M. An index on `region` enables an efficient seek. If the table is partitioned by region, this becomes a single-partition scan.

> **Interviewers Watch For**
>
> Whether you use `SELECT *` or list columns explicitly. Explicit column lists are preferred in production for schema stability and documentation.

> **Common Pitfall**
>
> Misspelling the region name or using incorrect casing. Region identifiers like 'us-east-1' are case-sensitive in most systems.

---

## Common follow-up questions

- How would you find entries that have already expired? _(Add AND expires < DATETIME('now') to filter expired entries.)_
- What if you needed entries from multiple regions? _(Use WHERE region IN ('us-east-1', 'us-west-2') for multi-region queries.)_
- How would the performance change if the table were partitioned by region? _(Partition pruning eliminates scanning other regions entirely.)_

## Related

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