Transcript: Test a database fix before production
Test a database fix before production. Download a test kit, run it on a copy, and compare before and after: time, logical reads, plan and results.
We are on the Drift page of the demo PostgreSQL database. This query got 9x slower after a release.
Open it to see the analysis and the fix.
The cause: a full scan of 4.2 million rows. The fix script adds an index on orders (member_id, status).
A fix that looks right on paper can still pick the wrong plan. So prove it first.
The test kit is a zip of plain SQL scripts. ReinDB is not connected while they run.
Run them in order with psql on a test copy, or in a quiet hour. Every step has a backup and an undo.
The kit picks a common and a rare value from the table itself. It never reads your application's bind values.
Each runs 5 times after a warm-up, before and after the fix, with the plan, logical reads and a checksum of the results.
Back on the Drift page, Compare test runs reads before.out and after.out in your browser. Nothing is uploaded.
Here we load the sample runs: this kit, run on a 2-million-row copy of the orders table.
Verdict: Better. Two value sets got faster, two did not change, and none got worse.
The results stayed the same: same rows, checksum matches. A different checksum would mean the fix changed the answer.
Rare values: 49.9 ms to 0.041 ms, and 16,990 logical reads to 4, on a new plan.
Common values: no change. Each value set is judged on its own, so a fix that helps one and hurts another shows up.
The generic plan rows show what a prepared statement may switch to after five runs.
Plans, before and after: a sequential scan of orders becomes an index scan on the new index.
After you deploy, mark the fix and Watch this fix follows it in production with the numbers ReinDB already keeps.
Here an earlier fix made this query 2.7x faster, but the latest hour shows it back again at 180 ms. ReinDB says so.
Test kits for PostgreSQL, MySQL, SQL Server and Oracle. See the Compare view on the live demo at reindb.com.