Auth Service Health Checks

An easy SQL interview practice problem on DataDriven. Write the query and run it against a real database, with instant feedback.

Domain
SQL
Difficulty
easy
Seniority
L3
Asked in
Vesta Innovations

Problem

The SRE team is investigating recent instability in the authentication service. Pull all health check records for 'auth-svc', including every available field.

One service. Full audit trail.

Tables

svc_health

Columns: check_id INTEGER, svc_name TEXT, status TEXT, latency REAL, uptime REAL, checked TEXT, region TEXT

svc_health: 10 of 200 rows
check_idsvc_namestatuslatencyuptimecheckedregion
137payment-apidegraded3.697.032026-02-02 01:05:00us-west-2
174user-svcunhealthy6.794.062026-03-03 02:10:00eu-west-1
211search-apitimeout9.891.092026-04-04 03:15:00ap-south-1
248gatewayHealthy12.998.122026-05-05 04:20:00eu-central-1
285notif-svcDEGRADED1695.152026-06-06 05:25:00us-east-1
322ml-servinghealthy19.192.182026-07-07 06:30:00us-west-2
359cache-svcdegradedNULL99.212026-08-08 07:35:00eu-west-1
396queue-workerunhealthy25.396.242026-09-09 08:40:00ap-south-1
433cron-svctimeout28.493.272026-01-10 09:45:00eu-central-1
470auth-svcHealthy31.590.32026-02-11 10:50:00us-east-1

Expected output

First 5 of 18 rows
check_idsvc_namestatuslatencyuptimecheckedregion
470auth-svcHealthy31.590.32026-02-11 10:50:00us-east-1
840auth-svcunhealthy62.590.62026-03-21 20:40:00us-east-1
1210auth-svchealthy93.590.92026-04-03 06:30:00us-east-1
4873auth-svcDEGRADED529.991.452026-04-20 09:03:00eu-west-1
5243auth-svctimeout570.993.952026-02-18 19:13:00eu-west-1

Worked solution and explanation

Why this problem exists in real interviews

A one-liner like this is a behavior test, not a SQL test. SRE handed you a 63M-row partitioned table and a vague ask. They want to see if you confirm the literal (auth-svc exact case), ask whether they need every check or the latest per region, and add an ORDER BY so the output is reproducible across runs.


Break down the requirements

Step 1: Confirm the literal

svc_name = 'auth-svc' is case-sensitive on most engines. Ask aloud whether the service name is stored exactly as auth-svc or with any variant before writing.

Step 2: Every field

SELECT * is correct here. The prompt says every available field. Naming columns would drift from the schema if SRE adds one tomorrow.

Step 3: Predicate on the right column

WHERE svc_name = 'auth-svc' filters before any partition pruning kicks in. The table is partitioned by checked, not svc_name, so this still scans every partition.

Step 4: Decide on ordering

Default order is undefined. For an SRE investigation, sort by checked DESC so the most recent checks render first. Mention the choice in the interview.


The solution

AUTH SERVICE HEALTH CHECKS
SELECT *
FROM svc_health
WHERE svc_name = 'auth-svc'

COMMON FOLLOW-UP QUESTIONS

Common follow-up questions