File size: 4,486 Bytes
d9db267
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
05338bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---

license: cc-by-nc-4.0
task_categories:
- text-generation
- question-answering
language:
- en
tags:
- sql
- database
- query-optimization
- explain-analyze
- postgresql
- mysql
- clickhouse
- cockroachdb
- dba
- fine-tuning
pretty_name: "Enterprise Database Query Plan Optimization & Remediation Traces"
size_categories:
- 100<n<1K
---


# Enterprise Database Query Plan Optimization & Remediation Traces (Community Preview)

<p align="center">
  <img src="dataset_product_cover_1024.png" alt="Dataset Banner" width="700"/>
</p>

## Overview
High-concurrency database workloads frequently degrade due to optimizer plan misestimations, unindexed correlated joins, merge-sort memory spills, and non-sargable expressions.

This repository hosts the **Community Preview (250 verified traces)** of an architectural fine-tuning dataset spanning **PostgreSQL 16, MySQL 8.0, ClickHouse 24, CockroachDB, MariaDB, and SQLite**. Each record pairs an authentic production query regression and raw execution plan (`EXPLAIN ANALYZE`) with chain-of-thought architectural diagnosis, actionable remediation DDL, and dialect-compliant optimized queries.

---

## Dataset Splits & Commercial Licensing

| Split | Records | Format | Primary Use Case | License |
| :--- | :--- | :--- | :--- | :--- |
| **Community Evaluation** (This Repo) | 250 | Parquet | Benchmarking, zero-shot eval, research | **CC BY-NC 4.0** |
| **Enterprise Commercial Corpus** | 2,500 | Parquet + JSONL | Production fine-tuning (SFT/DPO), commercial DBA agents | **Commercial Enterprise License** |

### Complete Enterprise Corpus (2,500 Records)
For production model deployment, proprietary agent training, or private RAG pipelines without non-commercial restrictions:

👉 **[Acquire Enterprise Commercial License & Dataset via Dodo Payments](https://checkout.dodopayments.com/buy/pdt_0NqD7nyGBW7fVDMd1Fm2l)**

---

## Data Structure & Schema

```json

{

  "database_engine": "string",

  "slow_query": "string",

  "execution_plan": "string",

  "diagnostic_thought": "string",

  "remediation_ddl": "string",

  "optimized_query": "string"

}

```

### Field Definitions

| Field | Data Type | Description |
| :--- | :--- | :--- |
| `database_engine` | `string` | Target engine dialect & exact version (e.g., `PostgreSQL 16.2`, `ClickHouse 24.3`). |
| `slow_query` | `string` | Realistic unoptimized SQL query triggering runtime performance degradation. |
| `execution_plan` | `string` | Raw optimizer output (`EXPLAIN (ANALYZE, BUFFERS)` or JSON plan) exposing node bottlenecks. |
| `diagnostic_thought` | `string` | Step-by-step reasoning diagnosing node cost, row estimate deltas, and I/O buffer behavior. |
| `remediation_ddl` | `string` | Executable DDL statements (`CREATE INDEX CONCURRENTLY`, table parameter tuning). |
| `optimized_query` | `string` | Performant rewritten query strictly adhering to engine dialect grammar. |

---

## Quickstart (Hugging Face Datasets)

```python

from datasets import load_dataset



# Load Community Preview

dataset = load_dataset("ayushjoshi2012/sql-optimization-diagnostic-traces", split="train")



# Inspect a single diagnostic trace

sample = dataset[0]

print(f"Engine: {sample['database_engine']}")

print(f"Slow Query:\n{sample['slow_query']}")

print(f"Diagnosis:\n{sample['diagnostic_thought']}")

print(f"Remediation DDL:\n{sample['remediation_ddl']}")

print(f"Rewritten Query:\n{sample['optimized_query']}")

```

---

## Core Domain Taxonomy

Traces are generated across representative enterprise schema designs:
* **Fintech & Ledger Core:** Double-entry ledger scans, implicit UUID-to-integer type coercion, balance aggregations.
* **IoT & Telematics:** Granule skip-index mismatches, partition decompression stalls, time-bucket groupings.
* **B2B SaaS & Security:** High-offset tenant audit logs, soft-delete booleans, unindexed RBAC joins.
* **Healthcare & EHR:** Unindexed composite foreign keys, leading-wildcard text filters, outdated optimizer statistics.
* **Freight & Global Logistics:** Disk-spilling merge joins on departure timestamps, Cartesian row multiplication.
* **AdTech & Gaming Telemetry:** Unindexed streaming click joins, unbounded window function sorts, leaderboard lock contention.

---

## Citation & Contact
For inquiries regarding custom synthetic domain generation, enterprise site licenses, or data additions, please commentinitiate a new discussion.