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
groupand 1.04x understrict. 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
EXISTSis 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
| KDBS | PostgreSQL | |
|---|---|---|
| Version | engine 9682b725, Release build; client a40882af (v3.3.0-38) | 18.6, built from source with stock -O2 |
| Settings | defaults, plus buffer_pool_frames = 65536; cores and durability set per cell | defaults: shared_buffers = 128MB, synchronous_commit = on, fsync = on |
| Durable at the reply | yes, under group and strict | yes, under synchronous_commit = on |
| Data | a fresh data file per cell, on ext4 | one cluster on the same ext4 device |
| Client | Python drivers, KWP wire protocol | Python 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*.pyandtools/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
| Workload | What it does | Size |
|---|---|---|
| 1 · Backtest | Loads market data, replays eight trading models over it, stores and compares their results, then reads and folds the data | 60,480 daily bars, 128,536 rows in 7 tables |
| 2 · Freight | A booking transaction: 4 reads, a freight insert, about six charge inserts, 2 updates and a durable commit | 300 organizations, 30 ships, 4,000 cargos; 3,000 bookings per cell |
| 3 · Library | 12 read shapes over users, books, loans and reservations, with and without indexes | 10,000 loans; also 200 and 1,000 |
| 4 · Trading days | Three simulated business days: open, a paced trading session of hot equality probes, a close of end-of-day folds, and a night | two 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:
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:
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:
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:
The two engines book at the same rate, 1.01x and 1.04x. Where the time of a booking goes differs:
| Part of a booking | KDBS | PostgreSQL | Difference |
|---|---|---|---|
| 4 reads | 405 µs | 322 µs | +83 µs |
| Writes: 1 freight, about six charges, 2 updates | 447 µs | 521 µs | −74 µs |
| Durable commit | 1,119 µs | 1,207 µs | −88 µs |
| Whole booking | 2,067 µs | 2,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:
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:
| Shape | No index | Indexed |
|---|---|---|
| Primary-key read of a user | 1.00x | 0.98x |
| Loans by user | 1.15x | 1.08x |
| Loans by book | 1.23x | 1.06x |
| Reservations by user | 1.16x | 1.04x |
| Books by author | 1.08x | 1.04x |
| Books by genre, about 125 rows | 0.96x | 0.84x |
| Loans in a 30-day range | 0.86x | 0.88x |
| Overdue loans | 0.99x | 0.83x |
| Loans joined to their user | 1.17x | 1.13x |
| Join on a key range, no literal | 1.12x | 2.96x |
Correlated EXISTS | 2.09x | 1.46x |
COUNT(*) of a user’s loans | 1.25x | 1.29x |
| Geometric mean | 1.14x | 1.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:
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.