External ORM Benchmarks (tortoise/orm-benchmarks)#
← All benchmarks · Runner: bench/orm_benchmarks/run.py · pgdorm adapter: pgdorm_bench.py
What this benchmark measures (and how to read the charts)#
Our main 10 PostgreSQL workloads are deliberately opinionated — they measure client CPU instructions and wire round trips (where lower is better). To answer "how does pgdorm perform on a standard benchmark written by someone else?", we run the well-known third-party tortoise/orm-benchmarks suite directly against PostgreSQL.
- Metric: Throughput in rows per second (
rows/s) — HIGHER IS BETTER. Longer bars mean more rows processed per second. - 33 workloads (3 models × 11 operations): Every ORM runs the same 11 CRUD operations (A–K) across three progressively heavier schemas:
- Test 1 · Simple (4 columns:
id,timestamp, indexedlevel, indexedtext). - Test 2 · Relations (adds a self-referencing
parentforeign key and a many-to-manyrelatedlink table). - Test 3 · Wide (35 columns: 4 copies each of
FLOAT,SMALLINT,INT,BIGINT,VARCHAR,TEXT,NUMERIC(12,8), andJSONB, split half defaulted / half nullable). - Concurrency: Async ORMs (
pgdorm, Tortoise, Piccolo, SQLAlchemy 2 async, SQLModel) run 10 concurrent coroutines (CONCURRENTS=10, upstream's default) withITERATIONS=1000. Synchronous ORMs (Django, Peewee) run sequentially just as upstream configures them. - Why Geometric Mean? Bulk inserts run at 50k–200k rows/s while single-row writes run at 2k–10k rows/s. A plain average would be completely drowned out by bulk scans; the geometric mean weights every operation equally on a relative scale.
Note
Upstream peer code & licence note. Rather than rewriting other ORMs ourselves, bench/orm_benchmarks/run.py clones and executes the verbatim peer ORM scripts directly from tortoise/orm-benchmarks so upstream improvements to Tortoise, Piccolo, SQLAlchemy, SQLModel, Django, and Peewee propagate automatically when refreshed.
At the time of writing, tortoise/orm-benchmarks does not ship a LICENSE file in its repository. We do not copy or redistribute upstream peer source files inside pgdorm; we only execute their public repository locally to generate the charts below. Our sincere apologies if running and referencing the suite here is unintended — please open an issue on GitLab and we will promptly adjust or remove it.
1. Overall Scoreboard (Geometric Mean across all 33 workloads)#
We show two pgdorm bars so the comparison stays completely transparent:
pgdorm(standard): Matches the exact sequential-loop-inside-a-transaction structure used by upstream peers in Ops B, I, J, and K (oneawaitper statement, ad-hoc query construction).pgdorm (prep+pipe): Usespgdorm's idiomatic compile-oncepg.prepare()andtx.pipeline(commit=True)so statements inside a transaction flush in 1 wire round trip instead of 100–300 sequential round trips.
Honest read — where pgdorm wins and where peers still beat it:
- Where
pgdormleads: Under 10 concurrent coroutines, Tokio multiplexes PostgreSQL I/O cleanly while Rust decodes binary tuples straight into__slots__— pushingpgdormahead of every peer on filtered reads (D, E), bulkUNNESTinserts (C), random PK lookups (F), and overall geometric mean even without pipelining. - Where sequential
pgdormtrails peers: When running a naive Pythonforloop that awaits one statement at a time inside a transaction (B batch insert, I/J single-row updates, K deletes), Tortoise ORM and Piccolo ORM beat unpipelinedpgdorm(e.g. ~15k–17k vs ~9.5k–10.7k rows/s in Test 1) because each individualawaitcrosses the PyO3 ↔ Tokio boundary. Switching that exact loop totx.pipeline(commit=True)flips it into a 10×–18× lead (~119k–195k rows/s). - Where Piccolo leads on wide dicts: In Test 3 (Wide) Op G (Filter dicts), Piccolo ORM (
189.5k rows/s) beatspgdorm(122.1k rows/s) becauseasyncpgmaterializes dict-like rows directly without a Pythondict(zip(...))pass. - Two deliberate API notes: Upstream's
Journalmodel uses a bareidPK (pgdormbinds it withstrict_pk=False), and upstream's Op E usesLIMIT 20 OFFSET <random>(sincepgdormintentionally omitsOFFSETin favor of keyset pagination,pgdormruns an equivalent 20-row keyset windowWHERE level = $1 AND id > $2 ORDER BY id LIMIT 20).
2. How Model Width Affects Throughput (Simple vs. Wide)#
Moving from a 4-column table (Test 1) to a 35-column table with NUMERIC(12,8) and JSONB (Test 3) stresses wire decoding and object hydration. Every ORM slows down on wider rows; Rust binary decoding + __slots__ retains a wide lead on both ends.
3. Breakdown by Operation Family#
Instead of making you squint at 250+ raw numbers, the two charts below group the 11 upstream operations (A–K) into their four natural workload families (geometric mean across Tests 1, 2, and 3; higher rows/s is better):
Writes (A–C) vs. Reads (D–F)#
- Writes: A single row insert · B transactional batch insert (loop inside 1 tx) · C bulk insert.
- Reads: D filter large (~600 rows per level as ORM models) · E filter small (20-row page) · F random primary-key
get().
Raw Projections (G–H) vs. In-Transaction Mutations (I–K)#
- Projections: G filter as Python
dicts · H filter as rawtuples (skipping full ORM model hydration). - Mutations: I update whole row · J update single column (
level) · K delete row — all run in transactions across ~3,000 rows split over 10 coroutines. Notice the sharp contrast between sequential awaits (pgdorm) and 1-RTT pipelining (pgdorm prep+pipe).
4. Dive Deeper: Exact Per-Operation Numbers (A–K)#
Want to inspect every individual operation (A through K) for a specific model? Expand any drawer below:
Test 1 · Simple model (4 columns) — raw rows/sec per operation (A–K)
| Op (rows/s, higher is better) | pgdorm | pgdorm (pipe) | Tortoise | Piccolo | Django | Peewee | SA 2 | SQLModel |
|---|---|---|---|---|---|---|---|---|
| A · Insert single | 7,399 | 7,763 | 5,836 | 5,351 | 1,907 | 2,214 | 3,201 | 2,217 |
| B · Insert batch (tx) | 9,718 | 119k | 15.8k | 14.2k | 2,525 | 3,402 | 24.3k | 10.6k |
| C · Insert bulk | 152k | 195k | 65.1k | 43.0k | 25.1k | 50.5k | 28.7k | 11.2k |
| D · Filter large | 1.32M | 1.42M | 225k | 272k | 159k | 279k | 198k | 172k |
| E · Filter small (20) | 130k | 182k | 43.6k | 36.0k | 18.6k | 33.4k | 46.3k | 43.9k |
| F · Get by PK | 11.4k | 9,353 | 5,657 | 5,503 | 2,240 | 3,028 | 7,357 | 7,899 |
| G · Filter dicts | 1.01M | 992k | 526k | 754k | 311k | 451k | 210k | 153k |
| H · Filter tuples | 1.57M | 1.63M | 478k | 677k | 309k | 450k | 608k | 635k |
| I · Update whole | 9,435 | 135k | 15.3k | 13.3k | 2,490 | 3,139 | 3,557 | 3,477 |
| J · Update partial | 9,862 | 124k | 16.4k | 13.6k | 2,464 | 3,461 | 3,787 | 3,834 |
| K · Delete | 10.7k | 183k | 17.1k | 15.2k | 2,734 | 3,685 | 3,839 | 3,827 |
| Geometric Mean | 59.6k | 163k | 39.4k | 38.1k | 12.6k | 18.5k | 23.1k | 18.3k |
Test 2 · Relations model (self-FK + M2M) — raw rows/sec per operation (A–K)
| Op (rows/s, higher is better) | pgdorm | pgdorm (pipe) | Tortoise | Piccolo | Django | Peewee | SA 2 | SQLModel |
|---|---|---|---|---|---|---|---|---|
| A · Insert single | 7,648 | 7,191 | 5,719 | 5,076 | 1,991 | 2,225 | 2,834 | 2,306 |
| B · Insert batch (tx) | 10.5k | 128k | 14.9k | 11.5k | 2,572 | 3,359 | 19.6k | 9,901 |
| C · Insert bulk | 177k | 200k | 55.7k | 22.2k | 20.1k | 44.2k | 20.8k | 10.5k |
| D · Filter large | 1.15M | 1.29M | 218k | 210k | 142k | 224k | 198k | 173k |
| E · Filter small (20) | 136k | 166k | 45.7k | 36.6k | 20.2k | 30.1k | 47.6k | 42.9k |
| F · Get by PK | 11.3k | 10.8k | 5,519 | 5,197 | 2,030 | 2,974 | 6,795 | 7,286 |
| G · Filter dicts | 939k | 995k | 503k | 704k | 273k | 424k | 206k | 144k |
| H · Filter tuples | 1.63M | 1.86M | 438k | 653k | 356k | 430k | 630k | 584k |
| I · Update whole | 9,611 | 149k | 14.7k | 12.6k | 2,238 | 3,382 | 3,038 | 3,472 |
| J · Update partial | 9,662 | 128k | 15.7k | 13.0k | 2,507 | 3,435 | 3,289 | 3,954 |
| K · Delete | 9,909 | 93.6k | 10.7k | 10.4k | 690 | 3,670 | 1,251 | 3,270 |
| Geometric Mean | 59.9k | 157k | 36.3k | 32.4k | 10.8k | 17.6k | 19.0k | 17.6k |
Test 3 · Wide model (35 columns + JSONB/Numeric) — raw rows/sec (A–K)
| Op (rows/s, higher is better) | pgdorm | pgdorm (pipe) | Tortoise | Piccolo | Django | Peewee | SA 2 | SQLModel |
|---|---|---|---|---|---|---|---|---|
| A · Insert single | 5,987 | 7,650 | 4,086 | 3,894 | 1,037 | 1,753 | 2,896 | 2,012 |
| B · Insert batch (tx) | 7,308 | 83.5k | 5,645 | 6,117 | 1,551 | 2,553 | 11.5k | 4,892 |
| C · Insert bulk | 35.0k | 36.5k | 13.8k | 8,077 | 8,910 | 11.4k | 14.5k | 5,360 |
| D · Filter large | 157k | 161k | 50.9k | 42.6k | 52.3k | 43.2k | 72.5k | 61.2k |
| E · Filter small (20) | 68.3k | 86.8k | 26.3k | 17.9k | 10.7k | 9,517 | 35.7k | 29.1k |
| F · Get by PK | 9,400 | 9,227 | 3,837 | 3,525 | 1,347 | 1,016 | 7,066 | 6,249 |
| G · Filter dicts | 120k | 122k | 93.6k | 190k | 70.0k | 71.9k | 64.2k | 44.5k |
| H · Filter tuples | 177k | 177k | 86.8k | 178k | 86.4k | 73.3k | 123k | 99.9k |
| I · Update whole | 9,026 | 115k | 11.4k | 6,013 | 1,319 | 1,854 | 2,995 | 2,921 |
| J · Update partial | 9,591 | 133k | 13.6k | 6,425 | 2,228 | 3,302 | 3,289 | 3,127 |
| K · Delete | 10.7k | 196k | 15.5k | 15.8k | 2,899 | 4,122 | 3,202 | 3,290 |
| Geometric Mean | 25.6k | 69.9k | 16.9k | 15.3k | 6,236 | 7,235 | 13.2k | 9,782 |
5. Environment & How to Reproduce#
- Upstream suite:
tortoise/orm-benchmarks@6a5b4eb(peer ORMs executed verbatim;pgdormviabench/orm_benchmarks/pgdorm_bench.py) - Metric: Throughput in rows/sec (higher is better), summarized via geometric mean across all 11 operations (A–K) × 3 model schemas
- Parameters:
ITERATIONS=1000·CONCURRENTS=10(async ORMs run 10 concurrent coroutines; sync Django/Peewee run sequentially as configured upstream) - Machine: Apple M1 Pro (8 cores · 32 GiB RAM) · Darwin 25.6.0 (arm64)
- Runtime: Python
3.15.2· PostgreSQL18.7 - Libraries: pgdorm
0.2.0(pgdorm-wire (Rust)) · pgdorm (prepared + pipe)0.2.0(pgdorm-wire (Rust)) · Tortoise ORM1.1.9(asyncpg) · Piccolo ORM1.39.0(asyncpg) · Django ORM6.1.3(psycopg3) · Peewee4.5.3(psycopg3) · SQLAlchemy 2 (async)2.1.9(asyncpg) · SQLModel0.0.50(asyncpg) - Snapshot:
2026-11-28T20:25:24+00:00· revrlktosxmqxpz/282ea16a1350
# Install benchmark peer ORMs and compile pgdorm in --release mode
uv sync --group dev --group docs --group bench
uv run --no-sync maturin develop --release
# Clones upstream tortoise/orm-benchmarks into a temp directory and runs all 8 contenders on PG 18
uv run --no-sync python -m bench.orm_benchmarks.run --iterations 1000 --concurrents 10