Skip to content

Add Postgres support for like-for-like benchmark comparisons#3

Open
MrLukeSmith wants to merge 20 commits into
mainfrom
feat/add-support-for-postgres
Open

Add Postgres support for like-for-like benchmark comparisons#3
MrLukeSmith wants to merge 20 commits into
mainfrom
feat/add-support-for-postgres

Conversation

@MrLukeSmith

Copy link
Copy Markdown
Contributor

Context

Adds Postgres as a second, selectable database engine so we can compare MySQL vs Postgres performance like-for-like with bin/bench compare.

Change summary

  • New --database mysql|postgres flag on bin/bench run (default mysql), backed by a new Bench::Engines registry and a Bench::PostgresClient mirroring Bench::MysqlClient.
  • docker-compose.yml gains a postgres service; only the selected engine's container is started per run.
  • Resource-limit flags/env vars/profile keys renamed from MySQL-specific to generic: --mysql-cpus/--mysql-memory--db-cpus/--db-memory, mysql:db: in profiles/*.yml, mysql_cpu metric → db_cpu.
  • bin/bench compare now shows which engine each side used; comparing MySQL vs Postgres under the same profile is not treated as a mismatch.
  • Breaking: old result.json files predate the database/db_cpu fields and the db_cpus profile key — comparing an old result against a new one will show blank values for those fields.

Technical considerations

  • Two bugs only surfaced via a live Postgres run, not unit tests: Postgres has no ROUND(double precision, integer) overload (needed an explicit ::numeric cast), and pg_stat_statements' query text can span multiple lines, which broke naive newline-per-row parsing — PostgresClient now parses psql --csv output via Ruby's CSV library instead. Both have regression coverage now, but there's no CI job against real Postgres/MySQL containers, so similar issues would again only surface via manual mise run smoke / --database postgres runs.
  • Gemfile now bundles pg unconditionally; its native extension needs libpq dev headers on the host (documented in the README).

MrLukeSmith and others added 20 commits July 10, 2026 11:15
…-db-cpus/--db-memory

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…_cpu

Comparing a mysql result against a postgres result no longer trips the
ProfileMismatch guard (that guard only checks topology/resource fields).
The Database row is purely informational.
Postgres has no ROUND(double precision, integer) overload, only
ROUND(numeric, integer) - discovered via Task 14's manual Postgres
smoke run, which failed with 'function round(double precision,
integer) does not exist' when fetching top statement digests.
pg_stat_statements' query text can span multiple lines (e.g. Rails'
own multi-line schema-introspection queries), which a bare
newline-per-row split shreds into bogus extra rows with empty
columns - discovered via Task 14's manual Postgres smoke run, whose
top_statements output was garbage. psql's --csv mode quotes
multi-line fields per RFC4180, so Ruby's CSV library parses them
correctly.
Cheap insurance recommended by the final whole-feature review - this
bug was only caught by a live Postgres run; without this assertion,
reverting the ::numeric cast would stay green in the unit suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant