Comparative Benchmark
A small, reproducible benchmark of DianaDB, MongoDB and PostgreSQL on one host: the same 10 000 documents and the same three queries for all three. The suite is one Node.js script and a Docker Compose file. Clone it, run it, and check the numbers on your own hardware.
Run of 2026-11-28 · DianaDB server 4.8.36 · @diana-db/odm 4.7.10 · MongoDB 9.0.8 · PostgreSQL 19.0 · Node.js 24.18.0
Workload
| Parameter | Value |
|---|---|
| Documents / rows | 10 000, from a seeded generator: every run and every database gets the same documents |
| Document shape | name string (one of 64 names), sex string, birthday date, tags array of 1 to 4 strings, score whole number below 1 000 000 (nearly every document has its own) |
| Insert | One document per call, each awaited before the next. No batches, no pipelining |
| Query 1: by name | name = "Diana Smith" (150 of the 10 000 documents), newest first, skip: 100, limit: 10. An equality on a value many documents share; 10 rows |
| Query 2: range | 500000 <= score < 510000: 92 of the 10 000 documents, all of them returned. The query an ordered index (a B-tree) is for |
| Query 3: sorted page | Every document, lowest score first, skip: 100, limit: 10; 10 rows |
| Checks | The script stops if a database returns another number of rows than the documents say |
| Query timing | Each query once, then 10 runs to warm up, then 200 runs: the median and the 95th percentile of those 200 |
| Clients | MongoDB - native driver · PostgreSQL - TypeORM · DianaDB - @diana-db/odm |
| Environment | All three servers in Docker on one host, one client process, default settings of every engine |
Insert - 10 000 documents
Total time. Lower is better.
The databases do not promise the same thing by default. PostgreSQL and DianaDB answer an insert after the write is on disk. MongoDB answers first and writes its journal within 100 ms; with j: true it waits for the journal too, and that row is the one to compare with the other two.
On single awaited inserts the three durable rows are close: DianaDB takes about 1.2× the time of PostgreSQL and of MongoDB with j: true. Every insert is its own round trip with its own write to disk, so the figure is the time of one durable request, times 10 000. To load many documents, use insertMany: one request and one write to disk for the whole batch.
Query 1 - by name, newest first, skip, limit
name = "Diana Smith", 150 documents match, 10 returned. Median of 200 runs. Lower is better.
DianaDB answers in about a millisecond with no index work: 4 times faster than MongoDB without an index. PostgreSQL is faster here even while it scans 10 000 rows (2.3 times), and with an index on name both are: MongoDB 1.8 times, PostgreSQL 4.2 times.
| Database | First run | As created | Index on name | ||
|---|---|---|---|---|---|
| Median | 95th percentile | Median | 95th percentile | ||
| DianaDB | 9.546 | 0.991 | 1.885 | 0.991 | 1.885 |
| PostgreSQL | 4.083 | 0.429 | 0.554 | 0.234 | 0.311 |
| MongoDB | 14.544 | 4.005 | 4.247 | 0.546 | 1.086 |
Query 2 - a range of scores
500000 <= score < 510000, 92 documents match and are returned. Median of 200 runs. Lower is better.
Measured on server 4.8.36, which tested every distinct score for each bound of the range. It is level with MongoDB without an index, and 4 to 5 times slower than MongoDB and PostgreSQL with an index on score. Server 4.11.0 answers a range from an ordered index; this result is from before it.
| Database | First run | As created | Index on score | ||
|---|---|---|---|---|---|
| Median | 95th percentile | Median | 95th percentile | ||
| DianaDB | 4.365 | 1.840 | 2.094 | 1.840 | 2.094 |
| PostgreSQL | 1.216 | 0.751 | 1.007 | 0.395 | 0.559 |
| MongoDB | 4.067 | 1.987 | 2.829 | 0.465 | 1.200 |
Query 3 - a sorted page of all documents
Every document, lowest score first, skip 100, limit 10. Median of 200 runs. Lower is better.
Measured on server 4.8.36, which compared every document to find the page. It is the slowest of the five here: 14 times slower than MongoDB and 17 times slower than PostgreSQL with an index on score, which read the page straight from the index. Server 4.11.0 reads a page sorted by a number from an ordered index; this result is from before it.
| Database | First run | As created | Index on score | ||
|---|---|---|---|---|---|
| Median | 95th percentile | Median | 95th percentile | ||
| DianaDB | 6.106 | 2.047 | 5.235 | 2.047 | 5.235 |
| PostgreSQL | 0.668 | 0.502 | 0.643 | 0.122 | 0.141 |
| MongoDB | 3.596 | 1.672 | 1.906 | 0.142 | 0.298 |
How to read the query columns
DianaDB stores every property with its index, so its queries always use one: there is nothing to create and nothing to forget. MongoDB and PostgreSQL are measured twice, as created (no index: a scan of 10 000 documents) and with indexes on name and score. DianaDB has one measurement per query; compare it with the indexed columns of the others for a like-for-like read. The first run is the first time a query is sent, before any warm-up. All times are in milliseconds. See Find and Count Documents.
Insert, in numbers
| Database | Total | Documents per second | Answers after the write is on disk |
|---|---|---|---|
| DianaDB | 9.133 s | 1 095 | Yes |
| PostgreSQL | 7.414 s | 1 349 | Yes |
| MongoDB (j: true) | 7.639 s | 1 309 | Yes |
| MongoDB (default) | 1.131 s | 8 844 | No: within 100 ms |
Reproduce it
Install dependencies:
npm i
Start the three servers:
docker pull databikers/diana-db:alpine docker compose build --no-cache diana-db docker compose up -d
Run the benchmark. It prints its tables and writes them to results.json:
npm start