Skip to content

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, indexed level, indexed text).
  • Test 2 · Relations (adds a self-referencing parent foreign key and a many-to-many related link table).
  • Test 3 · Wide (35 columns: 4 copies each of FLOAT, SMALLINT, INT, BIGINT, VARCHAR, TEXT, NUMERIC(12,8), and JSONB, split half defaulted / half nullable).
  • Concurrency: Async ORMs (pgdorm, Tortoise, Piccolo, SQLAlchemy 2 async, SQLModel) run 10 concurrent coroutines (CONCURRENTS=10, upstream's default) with ITERATIONS=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)#

Overall Geometric Mean — 33 Workloads (rows/sec, higher is better) Upstream tortoise/orm-benchmarks (Tests 1-3 x Ops A-K) executed verbatim on PG 18 Overall Geometric Mean — 33 Workloads (rows/sec, higher is better) Upstream tortoise/orm-benchmarks (Tests 1-3 x Ops A-K) executed verbatim on PG 18 pgdorm (prep+pipe): 121k rows/s pgdorm (prep+pipe) 121k rows/s (T1:163k · T3:69.9k) pgdorm: 45.0k rows/s pgdorm 45.0k rows/s (T1:59.6k · T3:25.6k) Tortoise ORM: 28.9k rows/s Tortoise ORM 28.9k rows/s (T1:39.4k · T3:16.9k) Piccolo ORM: 26.6k rows/s Piccolo ORM 26.6k rows/s (T1:38.1k · T3:15.3k) SQLAlchemy 2: 18.0k rows/s SQLAlchemy 2 18.0k rows/s (T1:23.1k · T3:13.2k) SQLModel: 14.7k rows/s SQLModel 14.7k rows/s (T1:18.3k · T3:9,782) Peewee: 13.3k rows/s Peewee 13.3k rows/s (T1:18.5k · T3:7,235) Django ORM: 9,463 rows/s Django ORM 9,463 rows/s (T1:12.6k · T3:6,236) Metric: rows/sec (higher is better) · upstream tortoise/orm-benchmarks (6a5b4eb) · ITERATIONS=1000, CONCURRENTS=10, PG 18

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 (one await per statement, ad-hoc query construction).
  • pgdorm (prep+pipe): Uses pgdorm's idiomatic compile-once pg.prepare() and tx.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 pgdorm leads: Under 10 concurrent coroutines, Tokio multiplexes PostgreSQL I/O cleanly while Rust decodes binary tuples straight into __slots__ — pushing pgdorm ahead of every peer on filtered reads (D, E), bulk UNNEST inserts (C), random PK lookups (F), and overall geometric mean even without pipelining.
  • Where sequential pgdorm trails peers: When running a naive Python for loop 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 unpipelined pgdorm (e.g. ~15k–17k vs ~9.5k–10.7k rows/s in Test 1) because each individual await crosses the PyO3 ↔ Tokio boundary. Switching that exact loop to tx.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) beats pgdorm (122.1k rows/s) because asyncpg materializes dict-like rows directly without a Python dict(zip(...)) pass.
  • Two deliberate API notes: Upstream's Journal model uses a bare id PK (pgdorm binds it with strict_pk=False), and upstream's Op E uses LIMIT 20 OFFSET <random> (since pgdorm intentionally omits OFFSET in favor of keyset pagination, pgdorm runs an equivalent 20-row keyset window WHERE 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.

By Model Width — Simple 4-Col vs. Wide 35-Col (rows/sec, higher is better) Geometric mean across all 11 operations (A-K) per model complexity By Model Width — Simple 4-Col vs. Wide 35-Col (rows/sec, higher is better) Geometric mean across all 11 operations (A-K) per model complexity Test 1: Simple (4 cols) Test 3: Wide (35 cols + JSONB) pgdorm (prep+pipe) pgdorm (prep+pipe): 163k/s 163k/s pgdorm (prep+pipe): 69.9k/s 69.9k/s pgdorm pgdorm: 59.6k/s 59.6k/s pgdorm: 25.6k/s 25.6k/s Tortoise ORM Tortoise ORM: 39.4k/s 39.4k/s Tortoise ORM: 16.9k/s 16.9k/s Piccolo ORM Piccolo ORM: 38.1k/s 38.1k/s Piccolo ORM: 15.3k/s 15.3k/s SQLAlchemy 2 SQLAlchemy 2: 23.1k/s 23.1k/s SQLAlchemy 2: 13.2k/s 13.2k/s Peewee Peewee: 18.5k/s 18.5k/s Peewee: 7,235/s 7,235/s SQLModel SQLModel: 18.3k/s 18.3k/s SQLModel: 9,782/s 9,782/s Django ORM Django ORM: 12.6k/s 12.6k/s Django ORM: 6,236/s 6,236/s Metric: rows/sec (higher is better) · upstream tortoise/orm-benchmarks (6a5b4eb) · ITERATIONS=1000, CONCURRENTS=10, PG 18


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().

Operation Families — Writes (A-C) vs. Reads (D-F) (rows/sec, higher is better) Geometric mean across all 3 models (Test 1 + Test 2 + Test 3) Operation Families — Writes (A-C) vs. Reads (D-F) (rows/sec, higher is better) Geometric mean across all 3 models (Test 1 + Test 2 + Test 3) Writes (A single, B tx, C bulk) Reads (D large, E small, F PK) pgdorm (prep+pipe) pgdorm (prep+pipe): 45.1k/s 45.1k/s pgdorm (prep+pipe): 96.3k/s 96.3k/s pgdorm pgdorm: 18.4k/s 18.4k/s pgdorm: 88.9k/s 88.9k/s SQLAlchemy 2 SQLAlchemy 2: 10.2k/s 10.2k/s SQLAlchemy 2: 35.0k/s 35.0k/s SQLModel SQLModel: 5,306/s 5,306/s SQLModel: 32.1k/s 32.1k/s Tortoise ORM Tortoise ORM: 12.8k/s 12.8k/s Tortoise ORM: 29.3k/s 29.3k/s Piccolo ORM Piccolo ORM: 9,779/s 9,779/s Piccolo ORM: 26.2k/s 26.2k/s Peewee Peewee: 5,708/s 5,708/s Peewee: 18.4k/s 18.4k/s Django ORM Django ORM: 3,831/s 3,831/s Django ORM: 14.5k/s 14.5k/s Metric: rows/sec (higher is better) · upstream tortoise/orm-benchmarks (6a5b4eb) · ITERATIONS=1000, CONCURRENTS=10, PG 18

Raw Projections (G–H) vs. In-Transaction Mutations (I–K)#

  • Projections: G filter as Python dicts · H filter as raw tuples (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).

Operation Families — Projections (G-H) vs. Mutations (I-K) (rows/sec, higher is better) Sequential in-tx loops (pgdorm) vs 1-RTT pipelining (pgdorm prep+pipe) vs peers Operation Families — Projections (G-H) vs. Mutations (I-K) (rows/sec, higher is better) Sequential in-tx loops (pgdorm) vs 1-RTT pipelining (pgdorm prep+pipe) vs peers Projections (G dicts, H tuples) Mutations (I whole, J part, K del) pgdorm (prep+pipe) pgdorm (prep+pipe): 634k/s 634k/s pgdorm (prep+pipe): 136k/s 136k/s Tortoise ORM Tortoise ORM: 277k/s 277k/s Tortoise ORM: 14.3k/s 14.3k/s Piccolo ORM Piccolo ORM: 446k/s 446k/s Piccolo ORM: 11.2k/s 11.2k/s pgdorm pgdorm: 610k/s 610k/s pgdorm: 9,822/s 9,822/s SQLModel SQLModel: 182k/s 182k/s SQLModel: 3,448/s 3,448/s Peewee Peewee: 241k/s 241k/s Peewee: 3,273/s 3,273/s SQLAlchemy 2 SQLAlchemy 2: 225k/s 225k/s SQLAlchemy 2: 3,012/s 3,012/s Django ORM Django ORM: 196k/s 196k/s Django ORM: 2,017/s 2,017/s Metric: rows/sec (higher is better) · upstream tortoise/orm-benchmarks (6a5b4eb) · ITERATIONS=1000, CONCURRENTS=10, PG 18


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; pgdorm via bench/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 · PostgreSQL 18.7
  • Libraries: pgdorm 0.2.0 (pgdorm-wire (Rust)) · pgdorm (prepared + pipe) 0.2.0 (pgdorm-wire (Rust)) · Tortoise ORM 1.1.9 (asyncpg) · Piccolo ORM 1.39.0 (asyncpg) · Django ORM 6.1.3 (psycopg3) · Peewee 4.5.3 (psycopg3) · SQLAlchemy 2 (async) 2.1.9 (asyncpg) · SQLModel 0.0.50 (asyncpg)
  • Snapshot: 2026-11-28T20:25:24+00:00 · rev rlktosxmqxpz/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