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. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.