Skip to content

docs(reference): benchmark MySQL and PostgreSQL backends - #315

Open
dimitri-yatsenko wants to merge 4 commits into
mainfrom
docs/backend-benchmark
Open

dimitri-yatsenko wants to merge 4 commits into
mainfrom
docs/backend-benchmark

Conversation

@dimitri-yatsenko

@dimitri-yatsenko dimitri-yatsenko commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds Reference → Backend Performance (src/reference/backend-performance.md). The page compares MySQL 8.0, MySQL 8.4, PostgreSQL 16 and PostgreSQL 17 on the same DataJoint queries:

  • fetches by primary key;
  • complex queries nested up to five levels deep;
  • in-table blobs, blobs in a file store, and JSON attributes.

It documents the method, the results by level of nesting, follow-up experiments that explain the largest differences, sensitivity passes and limits. Four SVG figures follow the site's light/dark theming. The page is linked from the Reference index and the Database Backends spec.

Findings

  • Small fetches by primary key take 70–165 µs per call on every engine.
  • Large in-table blobs are fetched 9–13× slower on PostgreSQL: a 4 MB value takes 0.64 ms on MySQL and 5.6–8.4 ms on PostgreSQL.
    • The cost is hex-encoding the value for transfer. Binary transfer is about 4× faster.
    • With blobs in a file store, the engines are even.
  • Cold, with in-table blobs, PostgreSQL is about 2–2.5× faster at every level. InnoDB's index leaf pages are scattered between the off-page blob pages, so read-ahead never triggers.
  • Warm, the results are mostly ties, with MySQL slightly ahead. Nesting depth by itself favors neither engine.
  • JSON: PostgreSQL renders whole documents as text 1.6–1.9× faster. MySQL extracts a key from large documents about 20× faster.
  • MySQL 8.4 reads cold data up to 1.9× slower per level than 8.0. Swapping innodb_flush_method between versions shows that the new O_DIRECT default is the cause.
  • PostgreSQL 17 matches 16, except that it sends large values about a third faster.
  • Every query returned identical results on all four engines.

Before merging

Merge after datajoint/datajoint-python#1671, the subquery pruning planned for 2.4. The page opens with a note that its results apply to DataJoint 2.4 and later, with pruning on by default, and links datajoint-python#1665, which describes the benefits of pruning. The measured build is master at eefe74b4 with #1671 merged in.

Checks

  • mkdocs build --strict passes.
  • scripts/check_links.py passes: internal links and images resolve across 146 pages.
  • scripts/check_markdown_lists.py passes.
  • Every number in the hand-written prose was recomputed from the raw benchmark results.

Add a Backend Performance reference page that compares MySQL 8.0, MySQL 8.4,
PostgreSQL 16 and PostgreSQL 17 on the same DataJoint queries: fetches by
primary key and complex queries nested up to five levels, with blobs stored in
the table, blobs in a file store, and JSON attributes. The page documents the
method, the results by level of nesting, follow-up experiments that explain the
largest differences, sensitivity passes and limits.

Link the page from the Reference index and the Database Backends spec.

This branch has not been deployed

No deployments
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