Dataset Viewer
Auto-converted to Parquet Duplicate
id
stringclasses
6 values
title
stringclasses
6 values
category
stringclasses
6 values
expected_detector
stringclasses
5 values
expected_root_cause
stringclasses
6 values
fix_target
stringclasses
3 values
naive_answer
stringclasses
6 values
naive_answer_correct
bool
2 classes
telemetry
dict
scenario_description
stringclasses
5 values
healthy_baseline
Healthy database
none
null
Nothing is wrong. The correct answer is no finding.
null
find something anyway
false
{ "statements": [ { "queryid": 455725342067307140, "query": "SELECT id, status, total_cents, created_at\n FROM orders\n WHERE user_id = $1\n ORDER BY created_at DESC\n LIMIT $2", "calls": 30, "total_exec_time": 20.982371999999998, "mean_exec_time": 0.6994123999999999, ...
null
missing_index
Missing index on a hot foreign key
indexing
missing_index
order_items.product_id has no index; the product-lookup query falls back to a sequential scan over the whole table.
database
add an index
true
{ "statements": [ { "queryid": -160921144486592860, "query": "SELECT o.id, o.created_at, oi.quantity\n FROM order_items oi\n JOIN orders o ON o.id = oi.order_id\n WHERE oi.product_id = $1\n ORDER BY o.created_at DESC\n LIMIT $2", "calls": 150, "total_exec_time": 11084.462094...
Drops idx_order_items_product_id and drives product-lookup traffic. The join seq-scans 2.5M rows on every call.
plan_regression
Plan regression from stale statistics
statistics
stale_stats
Statistics on orders are stale after a bulk load. The planner's row estimate for status = 'processing' is off by orders of magnitude, so it picks the wrong plan. Fix is ANALYZE orders, not a new index.
database
add an index on orders.status
false
{ "statements": [ { "queryid": 6567515492305370000, "query": "SELECT id, user_id, total_cents, created_at\n FROM orders\n WHERE status = $1 AND created_at > now() - interval $2\n ORDER BY created_at DESC\n LIMIT $3", "calls": 100, "total_exec_time": 7.046200999999999, "me...
Inserts 300k orders with a brand-new status value and blocks autovacuum, so pg_statistic never learns the value exists.
bloat
Table bloat — autovacuum disabled
vacuum
bloat
autovacuum is disabled on events, so dead tuples from UPDATE churn are never reclaimed. Fix is re-enabling autovacuum and vacuuming.
database
the table is just large
false
{ "statements": [ { "queryid": 6567515492305370000, "query": "SELECT id, user_id, total_cents, created_at\n FROM orders\n WHERE status = $1 AND created_at > now() - interval $2\n ORDER BY created_at DESC\n LIMIT $3", "calls": 30, "total_exec_time": 46.683979999999984, "me...
Disables autovacuum on events and runs repeated mass UPDATEs, leaving several hundred thousand dead tuples that never get reclaimed.
lock_contention
Lock contention — idle in transaction
locking
lock_contention
A session is idle-in-transaction holding row locks on orders. Blocked writers are waiting on it. Fix targets the holder, not the waiters.
session
kill the slow queries
false
{ "statements": [ { "queryid": 455725342067307140, "query": "SELECT id, status, total_cents, created_at\n FROM orders\n WHERE user_id = $1\n ORDER BY created_at DESC\n LIMIT 25", "calls": 30, "total_exec_time": 8.986045000000003, "mean_exec_time": 0.29953483333333336, ...
Leaves a session idle-in-transaction holding row locks on 1000 orders rows, plus three writers that block behind it.
n_plus_1
ORM N+1 query pattern
application
n_plus_1
Application-side N+1. order_items is queried once per order row instead of batched. High call count, low mean time, trivial rows per call. Fix is in the application, not the database.
application
nothing is slow, the database is healthy
false
{ "statements": [ { "queryid": 3395054879552150500, "query": "SELECT id, product_id, quantity FROM order_items WHERE order_id = $1", "calls": 1000, "total_exec_time": 59.843165000000084, "mean_exec_time": 0.059843165000000156, "rows": 2640, "shared_blks_read": 182, ...
Runs 20 pages x 50 rows of list-then-per-row-lookup traffic. No schema change: 1000 fast queries where 20 would do.

Postgres Incident Diagnosis Benchmark

Real telemetry from a Postgres 16 database in six states — one healthy, five broken — paired with the ground-truth root cause of each.

The task: given the stats views, say what is wrong. Or say that nothing is.

Why this exists

There is no standard benchmark for database incident diagnosis, so everyone building an AI SRE tool invents their own eval. This is a small, reproducible one with a specific property: on four of the five faults, the obvious answer is wrong.

id what a naive answer says actually correct
missing_index add an index ✅ yes
plan_regression add an index ❌ run ANALYZE — the schema is fine
bloat the table is just large ❌ dead tuples, autovacuum is off
lock_contention kill the slow queries ❌ they're victims; one holder is at fault
n_plus_1 nothing is slow, it's healthy ❌ 1000 calls at 0.04ms each
healthy_baseline find something anyway ❌ the answer is "no finding"

The healthy baseline is included deliberately: a diagnostic tool that invents problems on a working database is worse than one that misses them.

Baselines

Measured, not asserted. python -m evals.baselines reproduces this table.

approach score
always_index — always name something; for a database that's usually an index 1/6
slow_and_big — slowest statement over 10ms and a large table → missing index 2/6
deterministic detectors (reference implementation) 6/6

slow_and_big is right twice: it names the one genuine index problem, and it stays quiet on the healthy database. On the other four it returns nothing at all — once the rig's own statements are excluded (see below), none of those faults presents as a slow query. Stale statistics, bloat, a lock holder and an N+1 loop are all invisible to any heuristic that ranks by duration.

Telemetry contains application traffic only

Each scenario clears pg_stat_statements after the fault is created and before the workload runs, so the injector's own work never reaches the snapshot. Without that, plan_regression ships with a 9.6-second INSERT INTO orders … generate_series(1, 300000) and an ALTER TABLE orders SET (autovacuum_enabled = false) sitting in the statements, which name the root cause outright and make the scenario trivial.

For the same reason the healthy record is captured after running the same background traffic as every fault case — an empty statements list would make len(statements) == 0 a free correct answer.

Labels

expected_detector is one of missing_index, stale_stats, bloat, lock_contention, n_plus_1, or null for the healthy case. Six records, one per class, so treat this as a probe rather than a training set.

Fields

field description
id scenario identifier
title human-readable name
expected_root_cause ground truth, free text
expected_detector ground-truth label, null when healthy
category indexing, statistics, vacuum, locking, application, none
fix_target whether the fix is in the database, a session, or the application
naive_answer what a pattern-matching tool would say
naive_answer_correct whether that happens to be right
telemetry.statements pg_stat_statements rows
telemetry.tables pg_stat_user_tables + size + autovacuum_enabled
telemetry.activity pg_stat_activity rows
telemetry.blocking waiter → blocker edges from pg_blocking_pids()
telemetry.settings relevant pg_settings values

Usage

from datasets import load_dataset

ds = load_dataset("yashMaini/postgres-incident-diagnosis", split="train")

correct = 0
for r in ds:
    prediction = your_model(r["telemetry"])   # -> a detector name, or None
    correct += prediction == r["expected_detector"]

print(f"{correct}/{len(ds)}")

telemetry holds the raw stats rows. A useful prompt is usually telemetry["statements"] plus telemetry["tables"]; lock_contention is only solvable from telemetry["blocking"], which is the point of including it.

Reproducing

The telemetry is generated, not hand-written — each row is captured from a live Postgres after a scripted fault injection, against a deterministic 5.2M row dataset (setseed(0.42)).

git clone https://github.com/Yashmaini30/pg-reliability-agent
docker compose up -d --build
python -m evals.export_benchmark --out data/

The reference implementation in that repo scores 5/5 detected, 5/5 ranked first, 0 findings on the healthy baseline using deterministic rules and EXPLAIN (GENERIC_PLAN) — no model in the detection path.

Project overview, with the findings the detectors produce for each scenario: https://huggingface.co/spaces/yashMaini/pg-reliability-agent (a static page — the clickable sandbox runs locally from the repo above).

Caveats

  • Six records. This is a sharp probe, not a broad benchmark.
  • Synthetic e-commerce schema, single Postgres 16 instance.
  • Absolute timings reflect the machine that generated it; the ratios are the signal, not the milliseconds.
Downloads last month
27

Space using yashMaini/postgres-incident-diagnosis 1