KDBS against PostgreSQL 18.6: four workloads

Four application workloads on KDBS and on PostgreSQL 18.6 at its defaults, on the same host and device: a backtest that finishes 1.25x sooner, a durable booking that ties, a library that reads 1.14x faster, and trading days where a learned Cabin runs 2.5x to 2.8x of a sequential scan.

This is the second of two posts comparing KDBS with PostgreSQL 18.6. The first took one statement type at a time: insert, update, commit, read, join. This one runs four application workloads, each a driver that loads data, runs its transactions and queries, and checks the result. A workload shows what the statement-level numbers add up to once they are mixed, repeated and run against each other.

PostgreSQL is the floor here, not the target. A result well below it means something is wrong with the engine. A result above it says that workload is fine, and nothing more.

In short:

  • Backtest: the whole run takes 13.8 s on KDBS against 17.3 s on PostgreSQL, 1.25x. Most of the lead is the bulk load (1.48x). The replay’s joins run at 1.45x to 1.48x, its durable result inserts are even, and the whole-table folds are behind (0.68x).
  • Freight booking: one durable client books at 1.01x under group and 1.04x under strict. KDBS spends 83 µs more per booking reading, and saves 74 µs writing and 88 µs committing. With eight cores, the same booking reaches 3,930 tps at 32 clients.
  • Library: twelve read shapes over 10,000 loans run at a geometric mean of 1.14x, with or without indexes. The correlated EXISTS is at 2.09x, and the shapes that return many rows at 0.86x to 0.99x.
  • Trading days: with the Cabin controller learning the hot values, a 10,000-row board is served at 2.49x and a 10,000-row tape at 2.81x of a PostgreSQL sequential scan. End-of-day folds are at 0.68x.

How it was measured

KDBSPostgreSQL
Versionengine 9682b725, Release build; client a40882af (v3.3.0-38)18.6, built from source with stock -O2
Settingsdefaults, plus buffer_pool_frames = 65536; cores and durability set per celldefaults: shared_buffers = 128MB, synchronous_commit = on, fsync = on
Durable at the replyyes, under group and strictyes, under synchronous_commit = on
Dataa fresh data file per cell, on ext4one cluster on the same ext4 device
ClientPython drivers, KWP wire protocolPython twins of the same drivers, PostgreSQL wire protocol

The host is one 8-vCPU VM (AMD EPYC 9V74, 4 cores × 2 threads, Linux 7.0), and the client processes share those CPUs with the server. Both engines reply to COMMIT only after the commit record is on disk. group and strict differ only in how commits are batched, so PostgreSQL’s default is the counterpart of both (see Durability and the write-ahead log).

The rules each number follows:

  • Three runs per cell, and the median is reported. The spread of a cell is (max − min) / median over its runs. A difference smaller than the larger spread is not a result, and a cell whose spread is above 20% is not read.
  • Never concurrent. A gate held each cell until no build or test process was running, and a one-second monitor checked each cell’s window afterwards. Five cells overlapped a foreign process and were run again.
  • One binary. Every KDBS server started from a hashed copy of the same binary.
  • Unmodified drivers. Both sides ran the drivers as they are in the repository (tools/scenario*.py and tools/pg_scenario*.py).

As in the first post, the walks of large tables come from the morning run. PostgreSQL’s cells ran in the morning, in the same window as a KDBS run on the same engine binary with the previous client. Three hours later, the host walked the large integer tables 11% to 17% more slowly with either client, and the run did not explain why. For statements that walk a large table and return a handful of rows, which the client change does not touch, this post uses the morning’s KDBS cells. Every other number is from the later run.

Ratios are KDBS over PostgreSQL: above 1.00x means KDBS is faster. KDBS runs with cores = 1 unless a row says otherwise.

The four workloads

WorkloadWhat it doesSize
1 · BacktestLoads market data, replays eight trading models over it, stores and compares their results, then reads and folds the data60,480 daily bars, 128,536 rows in 7 tables
2 · FreightA booking transaction: 4 reads, a freight insert, about six charge inserts, 2 updates and a durable commit300 organizations, 30 ships, 4,000 cargos; 3,000 bookings per cell
3 · Library12 read shapes over users, books, loans and reservations, with and without indexes10,000 loans; also 200 and 1,000
4 · Trading daysThree simulated business days: open, a paced trading session of hot equality probes, a close of end-of-day folds, and a nighttwo 10,000-row boards; tapes of 200, 1,000 and 10,000 rows

1 · Backtest

The driver loads seven tables, replays eight trading models over 360 rebalances, inserts each model’s results durably, compares the models, and then reads and folds the data. Summed over every phase, one run takes 13.8 s on KDBS and 17.3 s on PostgreSQL, 1.25x. Per phase:

Backtest phases · KDBS over PostgreSQL
Load, 200 rows per transaction
Sessions, 7,560 rows21,906 vs 13,293 rows/s1.65x
Bars, 60,480 rows19,626 vs 13,337 rows/s1.47x
Daily stats, 60,480 rows19,197 vs 12,949 rows/s1.48x
Model replay
Read a cross-section: a three-table join531.7 vs 367.8 qps1.45x
Insert a result row, durable autocommit749.7 vs 779.8 rows/s0.96x
Replay the cross-sections575.4 vs 387.8 qps1.48x
Compare
One model's results, joined to the model1,026.9 vs 1,091.5 qps0.94x
Every result row, joined to its model101.0 vs 120.0 qps0.84x
Fold
One session's cross-section, grouped615.8 vs 413.4 qps1.49x
GROUP BY symbol, 8 groups133.1 vs 145.5 qps0.91x
GROUP BY session, 7,560 groups45.9 vs 50.1 qps0.92x
COUNT, MIN, MAX, SUM over the table165.2 vs 244.4 qps0.68x
COUNT(DISTINCT) over the table167.2 vs 244.6 qps0.68x
0.5x1x2x
← PostgreSQL fasterKDBS faster →

The load is more than half of the run on PostgreSQL and the clearest lead: 6.6 s against 9.7 s. The replay is a three-table join per rebalance, a walk of the day’s features probing bars and symbols by key, and it runs at 1.45x to 1.48x. The result rows between the joins are each a durable autocommit, so that step waits for the device on both engines and is even. The comparison phases return hundreds to thousands of rows and pay the per-row cost the first post describes. The whole-table folds are the one place in this workload where the engine itself is behind.

Cabins against a btree index

A Cabin serves column = value for the values queries actually ask for. The backtest runs its filter shapes a second time with a Cabin declared on the filtered column, against PostgreSQL with a btree index on the same column:

KDBS with a Cabin over PostgreSQL with a btree index
Three-table join from a filtered walk6,722 vs 4,595 qps1.46x
One session's features, 8 rows8,109 vs 8,722 qps0.93x
One model's results joined to the model1,041 vs 1,124 qps0.93x
One symbol's history, 7,560 rows26.2 vs 33.8 qps0.78x
0.5x1x2x
← PostgreSQL fasterKDBS faster →

On a join, the Cabin is ahead. On a single-table filter it is within 7% of the index, and behind where many rows come back.

More connections

The backtest also issues its three-table join over several connections at once, on both engines:

Three-table join throughput by connections
KDBS, cores = 8KDBS, cores = 1PostgreSQL
1 connection
540.6 qps
561.3 qps
456.4 qps
2 connections
1,020.6 qps
631.0 qps
870.2 qps
4 connections
1,131.8 qps
634.9 qps
892.5 qps
8 connections
1,588.5 qps
633.6 qps
874.6 qps

With cores = 1, KDBS stays near 630 qps from two connections on: one core’s statements run on one thread, so more connections only queue. PostgreSQL runs a process per connection over all eight CPUs. With cores = 8, KDBS is ahead at every connection count, 1.82x at eight. Those cells vary more between runs, 22% to 42% at four and eight connections, because sessions are placed on cores as they arrive. See Thread-per-core execution for how cores divides the work.

2 · Freight

A booking reads the cargo, the customer’s credit, the voyage’s capacity and the 93 pricing rules for the cargo type. Then it inserts the freight and its charges, updates the voyage and the customer, and commits durably. PostgreSQL’s twin drives one booking connection, so the comparison is one booker:

One booker, durable · bookings per second
KDBSPostgreSQL
KDBS, group
425.4 tps
KDBS, strict
434.3 tps
PostgreSQL, synchronous_commit = on
419.5 tps

The two engines book at the same rate, 1.01x and 1.04x. Where the time of a booking goes differs:

Part of a bookingKDBSPostgreSQLDifference
4 reads405 µs322 µs+83 µs
Writes: 1 freight, about six charges, 2 updates447 µs521 µs−74 µs
Durable commit1,119 µs1,207 µs−88 µs
Whole booking2,067 µs2,123 µs−56 µs

These are means per booking attempt, median of three runs. About 10% to 12% of attempts are rejected for capacity or credit after the reads and never write, which is why the commit here is below its own mean of 1,294 µs. KDBS is cheaper on every write and on the commit, and dearer on the reads, mostly the 93-row pricing read (148 µs against 96 µs). The commit is still more than half of a booking on both engines, so one client waits for its own fsync either way.

More bookers

The twin has no multi-client mode, so the rest has no PostgreSQL counterpart. It shows how the booking scales on KDBS with cores = 8:

Bookings per second by clients, cores = 8
groupstrict
1 booker
410.2 tps
416.5 tps
2 bookers
728.5 tps
580.2 tps
4 bookers
1,177.1 tps
994.0 tps
8 bookers
1,990.6 tps
1,716.7 tps
16 bookers
3,284.4 tps
2,507.0 tps
32 bookers
3,929.6 tps
3,387.4 tps

Throughput climbs 9.6x for 32 times the clients under group, and 8.1x under strict, which pays for its staged commit and for more retried conflicts. The host was at most 65% busy in any second, and every booker is a thread in one Python process, so the client is a likely bound. The engine’s ceiling has not been found yet.

A note on correctness

The driver checks four invariants 400 times while the bookings run. With eight bookers under the default isolation, 15 to 37 of those checks fail. That is not the engine losing data. The driver reads a voyage’s booked volume and later writes read + cbm back, which is a lost update under read committed. Under repeatable-read, all 400 checks pass: the engine refuses the second writer with TXN_CONFLICT, the driver retries, and throughput stays within 2% (672.0 against 681.3 tps at one core, 2,036.8 against 1,990.6 at eight). See Transactions and isolation.

3 · Library

Twelve read shapes, 200 statements each, over 10,000 loans, 2,000 users, 2,000 books and 5,000 reservations. The driver runs them once on bare tables and once with the indexes each shape can use:

ShapeNo indexIndexed
Primary-key read of a user1.00x0.98x
Loans by user1.15x1.08x
Loans by book1.23x1.06x
Reservations by user1.16x1.04x
Books by author1.08x1.04x
Books by genre, about 125 rows0.96x0.84x
Loans in a 30-day range0.86x0.88x
Overdue loans0.99x0.83x
Loans joined to their user1.17x1.13x
Join on a key range, no literal1.12x2.96x
Correlated EXISTS2.09x1.46x
COUNT(*) of a user’s loans1.25x1.29x
Geometric mean1.14x1.14x

Without indexes, every equality that returns a few rows is ahead, because KDBS walks a row faster (26 ns against 39 ns). With indexes, those shapes become a btree descent on both engines and close to even. The shapes behind are the ones that return many rows, in either mode. The no-literal join runs at 2.96x indexed because PostgreSQL does not use the index for it: its indexed rate is 0.98x of its own unindexed one. An index buys both engines about the same: 4.77x on KDBS and 4.47x on PostgreSQL for loans by user.

At 200 and 1,000 loans, a statement is mostly a round trip and many cells vary by more than 20% between runs, so no ratio there is read.

4 · Trading days

Three business days run against three KDBS servers at once: one with the Cabin controller off, one with it on, and one with a Cabin declared up front. Each day opens with 240 inserts into the day’s board, trades for 45 seconds of paced equality probes on hot symbols (2,400 on the board, 396 on each tape, 240 primary-key controls), closes with end-of-day folds, and sleeps through a 45-second night. The hot set moves: board_a on day 1, board_b on day 2, board_a again on day 3.

PostgreSQL’s twin runs day 1, with no index on the probed column:

Day 1 · KDBS over PostgreSQL with no index
Board, 10,000 rows · PostgreSQL 1,976 qps
Controller off, a walk2,565 qps1.30x
Controller on, a learned Cabin4,911 qps2.49x
Declared Cabin4,079 qps2.06x
Tape, 10,000 rows · PostgreSQL 2,100 qps
Controller off, a walk2,848 qps1.36x
Controller on, a learned Cabin5,910 qps2.81x
Declared Cabin4,751 qps2.26x
Tape, 1,000 rows · PostgreSQL 8,726 qps
Controller off, a walk8,526 qps0.98x
Controller on, a learned Cabin9,889 qps1.13x
Not served by a Cabin · controller on
Tape, 200 rows10,231 vs 12,484 qps0.82x
Primary-key control13,658 vs 14,409 qps0.95x
Open: 240 durable inserts832 vs 831 qps1.00x
Close: COUNT, SUM, GROUP BY801 vs 1,185 qps0.68x
0.5x1x2x
← PostgreSQL fasterKDBS faster →

Without a Cabin, KDBS walks the 10,000-row tables 1.30x and 1.36x faster than PostgreSQL. The controller then learns the hot values from the traffic: it creates four Cabins in the first 14 seconds of day 1. Served from a Cabin, a probe costs about 150 µs at the median on the board where the walk costs 387 µs. On a 200-row tape there is nothing to save, and that tape is 0.82x for a cost of about 13 µs per statement that this run does not attribute. The close is three whole-table folds, at 0.68x, the same gap as the backtest’s folds.

Over the three days, the controller keeps up with the traffic. It adds a Cabin for board_b in the first block of day 2. When board_a goes cold, its Cabin decays, and when board_a is hot again on day 3, the Cabin returns to active with its pages doubled. The learned Cabin’s lead over the walk grows from 1.90x on day 1 to 2.29x on day 3. Each day, the driver also compares 18 statements byte for byte across the three servers, and it passed on all three days in both runs: a Cabin changed no reply.

That PostgreSQL side has no index on the probed column, so these ratios say what a Cabin buys over a sequential scan, not over an index. The backtest’s comparison against a btree index is above.

A note on correctness

Every driver verifies what the engine returns, and no KDBS cell reported a wrong result. The freight driver’s invariant failures under read committed are the client’s lost update, explained above, and they disappear under repeatable-read.

What this run does not show

  • The ceiling under concurrency. The booker sweep stopped at 32 clients with the host mostly idle, driven from one Python process.
  • PostgreSQL with more than one booker. The freight twin drives one connection, so the multi-client numbers have no counterpart.
  • A Cabin against an index in the trading days. That twin has no index; the backtest’s comparison stands in for it.
  • Small tables. The library cells at 200 and 1,000 loans vary too much between runs to read a ratio.
  • PostgreSQL tuned. Both engines ran at their defaults. A tuned PostgreSQL, or one with an index where KDBS used a Cabin, would move some rows.
  • The latest engine. A change that streams a reply in batches as the walk proceeds came after this run. It is not in these numbers.
  • Other hardware. One VM, one ext4 device, clients on the same CPUs. A faster device could move the commit-bound rows in either direction.

Read the raw numbers

The four results files, the summary, every cell’s JSON and the run scripts are in the repository under bench/v3.3.0/, starting from the summary. The morning run the table walks come from is summarised beside it. Each file records its host, binary hash, per-cell load and spread. For the same engine one statement at a time, read the first post. To get a feel for the engine, try the sandbox, or run a server and point the drivers in tools/ at it.

More from the blog