SQL Benchmarks Lab

io.github.rctruta由 GitHub 帳號 rctruta 發布v0.1.2更新於 Oct 24, 2026

Query pre-computed SQL engine benchmarks. Runs standalone, no server setup required.

概覽

AI 產生的概覽

讓助理查詢預先算好的 SQL 引擎基準測試結果,並透過打包的 CLI 工具在本機執行基準實驗。

可以做什麼
提供對 SQL 基準實驗膠囊目錄的讀取工具,包括列出結果的工具,以及用來啟動新執行的 submit_experiment 工具。它可以在行程內掛載基準 REST API,不需要獨立伺服器,也可以指向在別處執行的 API。底層工具鏈會在 DuckDB、Postgres 等引擎上執行確定性、以雜湊定址的實驗。
適用情境
適合比較 SQL 引擎或查詢效能、重現已發佈的基準膠囊,或讓助理查詢既有基準資料而不是憑空猜測。最適合已經使用該基準實驗室或其已發佈結果的使用者。
執行需求
以 Python 套件(sqlbenchdag)透過 uvx 在本機執行,需要 Python 3.11+ 與 uv。容器化引擎(如 Postgres 與 TypeDB)需要 Docker,但僅用 DuckDB 的快速入門不需要。選用環境變數:SB_API_BASE 用於遠端 API 基礎網址,SB_RESULTS_DIR 用於實驗結果膠囊目錄。未宣告驗證機制。
安裝前請注意
此套件附帶 SQL 套件、分類法與範本,但不包含結果膠囊,因此全新安裝時目錄工具可用,而結果列表工具在存在執行結果前可能傳回空。submit_experiment 會啟動基準執行,可能重新啟動 Docker 容器並清空作業系統頁面快取,資源消耗較大。設定 SB_API_BASE 會將工具指向外部 API 端點。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 SQL Benchmarks Lab,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

SQL Benchmarking Laboratory

A deterministic, orchestrated harness for verifying database performance at scale. Developed by Ramona C. Truta

[SQL Benchmarks Lab MCP server]


The Mission: "Ground Truth" as Code

This platform is a specialized laboratory for testing SQL performance hypotheses. It transforms query tuning from intuition into a reproducible science.

The core of the system is a Deterministic Orchestration Harness that guarantees that if the logic or the environment changes, the benchmark result changes. If they do not, the result is addressable and cached.

Scope: the focus to date is synthetic and canonical (TPC-H) data, which is the right instrument for mechanism experiments — where controlled, reproducible data isolates the variable under test. Real-data support exists but is experimental; see the FAQ for the synthetic-vs-real rationale, the container model, and the roadmap (AI-security testbed, real-data trust chain).


Key Features & Innovations

1. Context-Aware Semantic Hashing (The Experiment ID)

The Heart of the system is the Experiment ID, an 8-character hash that governs the entire lifecycle. This hash is a SHA-256 fingerprint generated from:

  • The Config: Every dimension in your YAML (rows, skew, parameters).
  • The SQL Logic: The actual content of the benchmarked scripts.
  • The Code: All measurement-relevant Python — orchestration (assets/), engine clients (resources/), and data generators (plugins/).

Semantic Normalization: The hashing engine distinguishes between a logic change and a formatting change.

  • SQL: Comments, whitespace, and case are normalized before hashing.
  • Python: Orchestration scripts are parsed into an Abstract Syntax Tree (AST) to strip docstrings and formatting variations, ensuring the Experiment ID only changes when execution logic changes.

2. Multi-Layer Cold-Cache Isolation

To ensure IO-bound performance is not masked by memory buffers, engine-level buffers are cleared before every query:

  • Postgres: Mandatory Docker Container Restarts clear shared buffers.
  • Versioned DuckDB (duckdb_1_5, duckdb_2_0): every query runs in a fresh worker process, so DuckDB's buffer pool starts empty.

OS page cache: not evicted. Engines call thrash_os_cache, which dirties an anonymous memory region (half of available RAM, capped at 4 GB). On macOS this was measured to leave a cached 1 GB file fully resident, so measurements should be read as warm at the OS level. DuckDB clients take a required cold argument, and cold=True raises until a verified eviction step exists.

3. Agentic AI Integration

The platform is built for the future of Autonomous Engineering. The Experiment ID allows AI agents to treat the laboratory as a Deterministic Performance API.

  • See AGENTS.md for the full Agentic Benchmarking Protocol.

4. Declarative Matrix Orchestration

Benchmarks are defined as N-dimensional matrices in YAML. The platform expands these into a Cartesian product of Independent Dagster Partitions. This allows for parallel dispatch and granular retries.


Usage & Technical Setup

Prerequisites

  • uv: the project's Python environment & dependency manager (fast, modern). setup.sh uses it, and it can install Python 3.11 for you.
  • Python 3.11+: core runtime (uv provisions it if missing).
  • Docker: for the containerized engines (Postgres, TypeDB), which the harness manages itself — not required for the DuckDB-only quickstart.

Installation & Setup

From PyPI — the lab is installable, which gives you the tooling and the sqlbench CLI:

bash
pip install sqlbenchdag

From source — clone the repo to also get the published capsules (sql_benchmarks/experiments/results/) and the full harness. The laboratory includes a comprehensive setup script that manages virtual environments, dependencies, and directory initialization.

bash
# 1. Automate Setupchmod +x setup.sh && ./setup.sh
# 2. Activate Laboratorysource venv/bin/activate

The Execution Workflow (CLI)

While the system is powered by Dagster, the primary interface is the CLI for automated workflows.

bash
# QUICKSTART: DuckDB only, no Docker required — runs in seconds./run.sh sql_benchmarks/experiments/queue/quickstart.yaml --auto
# FULL BENCHMARK: Run all queued experiments (requires Docker for Postgres)./run.sh queue --auto
# SINGLE EXPERIMENT: Pass a specific config path./run.sh sql_benchmarks/experiments/queue/quack_execution_modes.yaml --auto

To write your own experiment, start from the annotated template and see the catalog of published runs in docs/experiments.md.


Project Structure

Managed with a strict separation between Harness and Scenario:

text
/sql_benchmarks├── /assets                 # THE HARNESS: Dagster factories & pipeline logic├── /resources              # THE INFRASTRUCTURE: DB drivers & Docker management├── /scripts/sql            # THE SCENARIOS: Raw SQL partitioned by scenario├── /plugins                # THE DATA: Declarative generators & scenario providers├── /utils                  # THE BRAIN: AST-hashing, common logic, & system primitives└── /experiments            # THE LABORATORY    ├── active.yaml         # LOCAL runtime staging — the coordinator overwrites    │                       #   this on every run (gitignored; not shared state)    ├── /queue              # Staging area for new experiment configs    ├── /archive            # Library of previously defined experiment templates    ├── /configs            # Registry of immutable, hash-addressed experiment capsules    └── /results            # Data capsules: fragments, CSVs, and Dashboards

Published Experiments — the Quack investigation

The first published study with this lab: an independent measurement of DuckDB's Quack client-server protocol (beta, v1.5.3). Each row links the runnable config to its committed, verifiable capsule. Full numbers, scaling exponents, and verification steps in docs/published_capsules.md.

ActQuestionConfigCapsuleFinding
IWhat does the protocol cost?quack_execution_modes.yamlb8e2bfafAttach-mode overhead grows with scan size (2.6× → 9.5× at 10M rows); pushdown stays flat at ~2×.
IIWhy is pushdown ~2× and not 1×?quack_residual_threads.yaml25b0e134The residual tracks reduced server-side parallelism (~2–4 of 8 threads), not transport.
IIIDoes it generalize to joins?tpch_quack_validation.yamlb198363eOn canonical TPC-H Q3, pushdown holds (~1.9×); attach mode cannot run the join at all (DNF).
IVDoes it beat the incumbent?quack_vs_postgres.yaml902d1277DuckDB-over-Quack (pushdown) beats PostgreSQL by up to 13.2×, and the gap widens with scale.

Act 0 (b82b4eae) is the exploratory scout that started it — see docs/published_capsules.md.

The lab also ships scenario suites for other studies — selectivity/, null_logic/, null_sentinel/, recursion/, sort_spill/, tpch/, and more under sql_benchmarks/scripts/sql/ — each runnable across the engine matrix.


Naming & Provenance

The lab works at two layers, named two different ways. Keeping them distinct is the difference between a number you can trace and a number you have to trust.

LayerWhat it isNamed byExample
Capsuleone experiment's complete resultsits Experiment ID — an 8-char SHA-256 of the question (config + SQL + measurement code), assigned by the machine48c92f31
Releasea signed set of capsules backing a publicationa human name: sqlbenchdag-<topic>-v<N>-<YYYYMMDD>sqlbenchdag-quack-v1-20260614

A release contains capsules; a capsule is one experiment. The machine names capsules (hashes you can't forge); the author names releases (words that mean something). sqlbenchdag is the lab's maker's mark — sql + bench + dag (Dagster, the orchestration that distinguishes this lab from a bare query timer). It is carried on every release this lab produces.

Two hashes, two jobs (a capsule contains both — they are not the same thing):

  • the Experiment ID (8 chars) is an address — it names the capsule, and the same question always produces the same address;
  • the integrity seal (64 chars, in integrity.seal) is a checksum — it verifies the capsule's contents are untouched. You file by the address; the seal is the tamper-evident lid.

Reproducibility is pinned to the release. Because the Experiment ID hashes the measurement code, it is stable only at a fixed code revision — which is exactly what the signed release tag freezes. To reproduce a published capsule, check out its release tag and re-run its config; the same question yields the same ID, or the comparison is refused by construction.

Provenance roadmap: a per-capsule generator stamp (sqlbenchdag@<commit>) will record the exact build that produced each capsule. It writes through the finalization code, which lives inside the Experiment-ID hash, so it ships with a future release rather than re-numbering capsules already published.

See docs/published_capsules.md for the full trust chain (reproducibility, integrity, timestamp, authorship) and how to verify each. Reproducibility and integrity are automatic on every run; timestamp and signature are optional steps you add only when publishing — the producer workflow is docs/PUBLISHING.md.


License

Copyright 2025-2026 Ramona C. Truta. Licensed under the Apache License 2.0.

Built with Dagster, Polars, Docker, DuckDB, and Postgres.

來源:README.md,提交 fb2ac80

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分