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.

  databikers/db-benchmark 

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

ParameterValue
Documents / rows10 000, from a seeded generator: every run and every database gets the same documents
Document shapename 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)
InsertOne document per call, each awaited before the next. No batches, no pipelining
Query 1: by namename = "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: range500000 <= 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
ChecksThe 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
EnvironmentAll three servers in Docker on one host, one client process, default settings of every engine

Insert - 10 000 documents

Total time. Lower is better.

MongoDB (default)
1.131 s
PostgreSQL
7.414 s
MongoDB (j: true)
7.639 s
DianaDB
9.133 s

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.

PostgreSQL, index
0.234 ms
PostgreSQL
0.429 ms
MongoDB, index
0.546 ms
DianaDB
0.991 ms
MongoDB
4.005 ms

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.

DatabaseFirst runAs createdIndex on name
Median95th percentileMedian95th percentile
DianaDB9.5460.9911.8850.9911.885
PostgreSQL4.0830.4290.5540.2340.311
MongoDB14.5444.0054.2470.5461.086

Query 2 - a range of scores

500000 <= score < 510000, 92 documents match and are returned. Median of 200 runs. Lower is better.

PostgreSQL, index
0.395 ms
MongoDB, index
0.465 ms
PostgreSQL
0.751 ms
DianaDB
1.840 ms
MongoDB
1.987 ms

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.

DatabaseFirst runAs createdIndex on score
Median95th percentileMedian95th percentile
DianaDB4.3651.8402.0941.8402.094
PostgreSQL1.2160.7511.0070.3950.559
MongoDB4.0671.9872.8290.4651.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.

PostgreSQL, index
0.122 ms
MongoDB, index
0.142 ms
PostgreSQL
0.502 ms
MongoDB
1.672 ms
DianaDB
2.047 ms

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.

DatabaseFirst runAs createdIndex on score
Median95th percentileMedian95th percentile
DianaDB6.1062.0475.2352.0475.235
PostgreSQL0.6680.5020.6430.1220.141
MongoDB3.5961.6721.9060.1420.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

DatabaseTotalDocuments per secondAnswers after the write is on disk
DianaDB9.133 s1 095Yes
PostgreSQL7.414 s1 349Yes
MongoDB (j: true)7.639 s1 309Yes
MongoDB (default)1.131 s8 844No: 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