Skip to main content

DBReduce logo

DBReduce

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

PyPI Python 3.13+ 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.

See CHANGELOG.md for release history.

Documentation

Licensed under Apache-2.0.

Metadata

Release files for dbreduce 0.3.1

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.1
File Size Uploaded
dbreduce-0.3.1.tar.gz 81.9 kB Details

Built distribution (wheel)

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

Total release size: 118.0 kB

Release files / dbreduce-0.3.1.tar.gz

Download URL dbreduce-0.3.1.tar.gz
Size 81.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a296312a368f9a7e5c80c618b219ccee0ac65477a6d304cc5c59d9efba1277c1
BLAKE2b-256 checksum
How to use checksums
c34ad736cd2e9cd38d8a7e9079ca8757749215e82f43ff043056901a1ada4ffc
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.1-py3-none-any.whl

Download URL dbreduce-0.3.1-py3-none-any.whl
Size 36.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
439eb5b6e1057d22375760598755f7a25f0f9c05fb1233090c0411d5672b7913
BLAKE2b-256 checksum
How to use checksums
0f2aff11f0269739aa02c6f6e74667afc289615daef6c3c5d9e4c3a507b1d0d9
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

This release

0.3.1 This release

2 release files

0.3.0

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