Skip to main content

DBReduce

Give DBReduce a PostgreSQL database and a failing test. It finds a smaller relational dataset that still reproduces the same bug.

PyPI Python License Tests

DBReduce reduces PostgreSQL data while checking that each candidate preserves the original failure identity. It supports output matchers and structured JSON verdicts, keeps oracle writes out of accepted data, and follows both PostgreSQL foreign keys and explicitly configured application relationships.

Quick start

DBReduce requires Python 3.13 or newer, PostgreSQL, and client tools (pg_dump and pg_restore) compatible with your server. Install it with:

python -m pip install dbreduce

Then reduce a database with a test that identifies the bug:

dbreduce reduce \
  --database postgresql://localhost/app_bug \
  --oracle 'uv run pytest tests/test_checkout.py::test_negative_total' \
  --match-stdout 'AssertionError: negative total' \
  --confirm 3

The oracle must connect through DATABASE_URL or DBREDUCE_DATABASE_URL. DBReduce sets both variables to its disposable workspace for every run. Use a database role with CREATEDB permission. The source database is read only; reductions and oracle executions run against a generated copy. Use trusted commands and dumps: SQL functions, triggers, and external services can have effects outside that copy.

For an oracle that can report a stable signature directly, use --oracle-json and have it write {"reproduced": true, "signature": "checkout-negative-total"} to stdout. See the guide for the verdict protocol and safety details.

Version 0.3.0 adds --oracle-framed-json for applications that log to stdout, --restore-jobs N for parallel custom-archive restores, and an experimental, opt-in PostgreSQL 17/18 --candidate-backend clone. Snapshot isolation remains the default. Clone mode verifies a final logical restore before publishing SQL.

What it does

  • Checks failure identity so an unrelated error does not count as reproducing the bug.
  • Isolates each oracle run so its database writes do not affect later candidates.
  • Reduces through real foreign keys and declared single or composite relationships.
  • Reports the final identity, candidate outcomes, timings, and row counts without saving raw oracle output.

Without an identity matcher, legacy mode accepts any nonzero application exit status and prints a warning. The result is locally irreducible under attempted relationship-closed transformations; DBReduce does not promise a global minimum. By default, DBReduce writes dbreduce.min.sql and dbreduce-report.json and never overwrites existing files.

Real-world validation

DBReduce v0.2.0 and v0.3.0 were validated with real Wagtail and NetBox schemas and application oracles. Wagtail's surrounding data was generated application noise, not a production dump. The 1,335-row NetBox database was reconstructed; the issue author's exact dump is unavailable. A separate v0.3.0 run used the official NetBox 4.1 demo dump as a public alternative and passed a fresh restore check. NetBox validation exercised its form path, not a full HTTP flow:

Wagtail #9208
150,706 rows
    v
DBReduce
    v
3 rows

same failure preserved
fresh restore verified
NetBox #17498
1,335 rows
    v
DBReduce
    v
2 rows

same failure preserved
fresh restore verified

See the real-world validation report and case studies for commands, environment, performance numbers, and limitations.

Documentation

Licensed under Apache-2.0.

Metadata

Release files for dbreduce 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbreduce 0.3.0
File Size Uploaded
dbreduce-0.3.0.tar.gz 80.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dbreduce 0.3.0
File Interpreter ABI Platform
dbreduce-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 115.9 kB

Release files / dbreduce-0.3.0.tar.gz

Download URL dbreduce-0.3.0.tar.gz
Size 80.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bc72b9dbe363fc2b75191f71ed1f9f5326ad187963aa7d070e61ea5168b75edb
BLAKE2b-256 checksum
How to use checksums
02e75537e9face49f25ae2c2d6261e187df39d2f0bb34105ff256b43949da10b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / dbreduce-0.3.0-py3-none-any.whl

Download URL dbreduce-0.3.0-py3-none-any.whl
Size 35.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f21179200fc4566e7c1d8a439a01a09caeacab81eef943e9aad57f19365a3f26
BLAKE2b-256 checksum
How to use checksums
81034871490b9580bd8a9ad5f1054719854ad7e39c501e009ec282f8df881951
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page