Nested JSON: Objects Inside Objects
Before you trust these numbers
- The author of NpgsqlRest runs this benchmark, and NpgsqlRest is one of the services in it.
- The analysis was written with AI assistance from the raw data, then reviewed and edited.
- Every test ran once, on one machine. Treat differences of a few percent as a tie.
- Everything is public so you can check it: the code of every service, the data, and everything that went wrong, and how to run it yourself. Corrections and pull requests are welcome.
What this test does
The service calls a function that returns 100 rows, each with a jsonb column holding an object nested 1, 2 or 3 levels deep. The work is in getting JSON out of the database and into the response without damaging it or paying for it twice.
It is run at 50 and 100 users at the same time.
The code that ran: the load script scenarios/nested-json.js, the PostgreSQL function in init.sql (for the NpgsqlRest SQL file services: perf-nested.sql), and each service's own source, linked from Every Service, One Scorecard.
How to read the charts
- A bar is requests answered per second. Longer is faster. The fastest service is at the top.
- A "k6 limit" or "PG limit" tag means the load generator (k6, the tool that sends the requests) or the database ran out of CPU before the service did. That service could have gone faster than its bar shows.
- The Highlight buttons above keep one platform highlighted in every chart of the series.
Six services return the nested object as a string
Go, Gin, Django, FastAPI, Swoole and Laravel Octane return the jsonb column as a JSON string, not as a nested object: PostgreSQL's text is passed through instead of being written as JSON. Their numbers are measured correctly, but they do less work here than the others, which is a large part of the lead of Go and Gin in this kind of test. They are marked with † in the tables.
In most of these tests the load generator was the limit (the k6 limit tag), which is why so many services sit at almost the same number.
What the numbers say
- Go and Gin are first in all six tests, by a wide margin at depth 2 and 3. They pass PostgreSQL's JSON text through as a string; the box above says what that means.
- Behind them, about twenty services are at the same number. That is the load generator's limit, not theirs.
- Read this page for the bottom half, where the services are the limit: PostgREST, the GraphQL servers, Django and Laravel Octane.
Of the 186 tests on this page, the service was out of CPU in 39, the load generator in 120, PostgreSQL in 0, and nothing in 27 (in those, the number of users set the pace, not a lack of CPU). A throughput number says how much a service can carry only where the service itself was out of CPU.
Compare the services
Pick a test with the buttons. Choose the number of users and the size, and what to look at: requests per second, how slow the slowest requests are, memory, or requests per CPU core. The chart starts on the main test of this kind (50 users, depth 1), which the summary tables of the series use.
↑ longer bar is betterHow many requests each service answered per second, with 50 users sending requests at the same time.
- 1Go 1.27 · net/http20,264req/sk6 limit
- 2Gin 1.12 (Go)19,865req/s
- 3Axum 0.8 (Rust)16,355req/sk6 limit
- 4Bun 1.416,267req/sk6 limit
- 5Actix-web 4.20 (Rust)16,231req/sk6 limit
- 6NpgsqlRest 4.1 JIT · SQL files16,220req/sk6 limit
- 7.NET 10 · plain Npgsql16,206req/sk6 limit
- 8Swoole 6.2 (PHP)16,160req/s
- 9NpgsqlRest 4.1 JIT · functions16,129req/sk6 limit
- 10.NET 10 · Dapper16,053req/sk6 limit
- 11Deno 2.916,042req/sk6 limit
- 12NpgsqlRest 4.1 AOT · functions16,021req/sk6 limit
- 13NpgsqlRest 4.1 AOT · SQL files15,994req/sk6 limit
- 14.NET 11 · Dapper15,947req/sk6 limit
- 15.NET 11 · plain Npgsql15,926req/sk6 limit
- 16NpgsqlRest 3.21 JIT · functions15,829req/sk6 limit
- 17NpgsqlRest 3.21 JIT · SQL files15,827req/sk6 limit
- 18NpgsqlRest 3.21 AOT · functions15,822req/sk6 limit
- 19NpgsqlRest 3.21 AOT · SQL files15,792req/sk6 limit
- 20Spring Boot 4.2 (Java 25)15,766req/sk6 limit
- 21Fastify 5.1214,749req/s
- 22Express 5.313,368req/s
- 23NestJS 12.612,977req/s
- 24.NET 11 · EF Core10,873req/s
- 25.NET 10 · EF Core10,842req/s
- 26PostgREST 16.66,267req/s
- 27FastAPI 0.1653,692req/s
- 28Hasura 2.50 (GraphQL)3,543req/s
- 29PostGraphile 5.2 (GraphQL)2,640req/sk6 limit
- 30Django 6.12,328req/s
- 31Laravel Octane 13.431,723req/s
The code of this test:the script that sends the requests · the PostgreSQL function it calls · the same as a SQL file. Click a service's name (↗) to open its own code for this test.
At 50 users at the same time, depth 1, Go 1.27 · net/http is first with 20,264 requests per second, 2.0% ahead of Gin 1.12 (Go). 2 of the 31 services are within 10% of the leader, and the slowest does 1,723.
The best of each platform
The fastest service of every platform in the main test (50 users, depth 1). "Compared with the fastest" is its requests per second as a percentage of the service in first place.
| Platform | Its fastest service | Place among the 31 | Requests per second | Compared with the fastest | Its code |
|---|---|---|---|---|---|
| Go | Go 1.27 · net/http | 1 | 20,264 | 100% | main.go |
| Rust | Axum 0.8 (Rust) | 3 | 16,355 | 81% | main.rs |
| Bun & Deno | Bun 1.4 | 4 | 16,267 | 80% | app.ts |
| NpgsqlRest | NpgsqlRest 4.1 JIT · SQL files | 6 | 16,220 | 80% | appsettings.json |
| .NET | .NET 10 · plain Npgsql | 7 | 16,206 | 80% | Program.cs |
| PHP | Swoole 6.2 (PHP) | 8 | 16,160 | 80% | server.php |
| Java | Spring Boot 4.2 (Java 25) | 20 | 15,766 | 78% | Application.java |
| Node.js | Fastify 5.12 | 21 | 14,749 | 73% | app.js |
| PostgREST | PostgREST 16.6 | 26 | 6,267 | 31% | postgrest.conf |
| Python | FastAPI 0.165 | 27 | 3,692 | 18% | app.py |
| GraphQL | Hasura 2.50 (GraphQL) | 28 | 3,543 | 17% | databases.yaml |
Every measurement of the main test
Latency, CPU, memory and time in PostgreSQL for all 31 services
| # | Service | Requests/s | Median ms | p99 ms | CPU cores used | Requests/s per core | Peak memory MB | Time in PostgreSQL | Out of CPU |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Go 1.27 · net/http † | 20,264 | 1.41 | 6.2 | 2.72 | 7,443 | 32 | 11% | k6 |
| 2 | Gin 1.12 (Go) † | 19,865 | 1.46 | 6.3 | 2.78 | 7,157 | 34 | 11% | — |
| 3 | Axum 0.8 (Rust) | 16,355 | 1.56 | 7.4 | 2.77 | 5,901 | 19 | 6% | k6 |
| 4 | Bun 1.4 | 16,267 | 1.61 | 7.6 | 2.56 | 6,364 | 161 | 10% | k6 |
| 5 | Actix-web 4.20 (Rust) | 16,231 | 1.65 | 7.7 | 2.74 | 5,920 | 29 | 6% | k6 |
| 6 | NpgsqlRest 4.1 JIT · SQL files | 16,220 | 1.60 | 7.1 | 2.19 | 7,421 | 119 | 11% | k6 |
| 7 | .NET 10 · plain Npgsql | 16,206 | 1.58 | 7.2 | 3.15 | 5,146 | 103 | 5% | k6 |
| 8 | Swoole 6.2 (PHP) † | 16,160 | 2.36 | 6.3 | 3.53 | 4,582 | 81 | 4% | service |
| 9 | NpgsqlRest 4.1 JIT · functions | 16,129 | 1.60 | 7.2 | 2.19 | 7,361 | 124 | 10% | k6 |
| 10 | .NET 10 · Dapper | 16,053 | 1.65 | 7.1 | 3.10 | 5,184 | 102 | 5% | k6 |
| 11 | Deno 2.9 | 16,042 | 1.72 | 7.8 | 2.70 | 5,939 | 299 | 10% | k6 |
| 12 | NpgsqlRest 4.1 AOT · functions | 16,021 | 1.65 | 7.3 | 2.47 | 6,486 | 54 | 10% | k6 |
| 13 | NpgsqlRest 4.1 AOT · SQL files | 15,994 | 1.66 | 7.2 | 2.45 | 6,535 | 57 | 11% | k6 |
| 14 | .NET 11 · Dapper | 15,947 | 1.69 | 7.4 | 2.53 | 6,313 | 113 | 5% | k6 |
| 15 | .NET 11 · plain Npgsql | 15,926 | 1.70 | 7.4 | 2.34 | 6,810 | 117 | 5% | k6 |
| 16 | NpgsqlRest 3.21 JIT · functions | 15,829 | 1.71 | 7.4 | 3.13 | 5,062 | 130 | 10% | k6 |
| 17 | NpgsqlRest 3.21 JIT · SQL files | 15,827 | 1.72 | 7.2 | 3.00 | 5,272 | 137 | 11% | k6 |
| 18 | NpgsqlRest 3.21 AOT · functions | 15,822 | 1.72 | 7.3 | 2.82 | 5,606 | 79 | 10% | k6 |
| 19 | NpgsqlRest 3.21 AOT · SQL files | 15,792 | 1.73 | 7.3 | 2.79 | 5,654 | 92 | 11% | k6 |
| 20 | Spring Boot 4.2 (Java 25) | 15,766 | 1.74 | 7.8 | 2.92 | 5,392 | 1,250 | 10% | k6 |
| 21 | Fastify 5.12 | 14,749 | 2.22 | 7.5 | 3.27 | 4,513 | 407 | 9% | — |
| 22 | Express 5.3 | 13,368 | 2.78 | 7.3 | 3.60 | 3,711 | 443 | 8% | service |
| 23 | NestJS 12.6 | 12,977 | 2.96 | 7.1 | 3.62 | 3,581 | 506 | 8% | service |
| 24 | .NET 11 · EF Core | 10,873 | 3.44 | 8.5 | 3.66 | 2,971 | 160 | 3% | service |
| 25 | .NET 10 · EF Core | 10,842 | 3.54 | 7.8 | 3.82 | 2,837 | 149 | 3% | service |
| 26 | PostgREST 16.6 | 6,267 | 7.09 | 9.7 | 2.96 | 2,120 | 73 | 3% | — |
| 27 | FastAPI 0.165 † | 3,692 | 12.12 | 15.5 | 3.83 | 964 | 212 | 0% | service |
| 28 | Hasura 2.50 (GraphQL) | 3,543 | 13.22 | 17.9 | 2.39 | 1,482 | 212 | 3% | — |
| 29 | PostGraphile 5.2 (GraphQL) | 2,640 | 3.12 | 31.5 | 2.08 | 1,267 | 844 | 4% | k6 |
| 30 | Django 6.1 † | 2,328 | 19.18 | 35.6 | 3.45 | 674 | 401 | 1% | service |
| 31 | Laravel Octane 13.43 † | 1,723 | 23.97 | 51.8 | 3.82 | 450 | 758 | 1% | service |
"CPU cores used" is the average CPU of the service during the test (it may use 4). "Time in PostgreSQL" is the share of an average request that PostgreSQL spent executing the statement.
All tests of this kind
Requests per second of every service in every test of this kind. Each column is one test; a higher number is better.
| Service | 50 users, depth 1 | 50 users, depth 2 | 50 users, depth 3 | 100 users, depth 1 | 100 users, depth 2 | 100 users, depth 3 |
|---|---|---|---|---|---|---|
| Go 1.27 · net/http † | 20,264ᵏ | 18,986ᵏ | 18,250ᵏ | 20,589ᵏ | 19,105ᵏ | 18,543ᵏ |
| Gin 1.12 (Go) † | 19,865 | 18,608ᵏ | 17,897ᵏ | 20,297ᵏ | 18,968ᵏ | 18,455ᵏ |
| Axum 0.8 (Rust) | 16,355ᵏ | 12,210ᵏ | 9,254ᵏ | 15,852ᵏ | 11,742ᵏ | 8,908ᵏ |
| Bun 1.4 | 16,267ᵏ | 12,206ᵏ | 9,303ᵏ | 15,807ᵏ | 11,641ᵏ | 8,917ᵏ |
| Actix-web 4.20 (Rust) | 16,231ᵏ | 12,206ᵏ | 9,286 | 15,905ᵏ | 11,685ᵏ | 8,932ᵏ |
| NpgsqlRest 4.1 JIT · SQL files | 16,220ᵏ | 12,153ᵏ | 9,224 | 15,669ᵏ | 11,582ᵏ | 8,897ᵏ |
| .NET 10 · plain Npgsql | 16,206ᵏ | 12,087ᵏ | 9,307 | 15,673ᵏ | 11,493ᵏ | 8,890ᵏ |
| Swoole 6.2 (PHP) † | 16,160 | 15,582 | 14,826 | 16,687 | 16,324 | 15,542 |
| NpgsqlRest 4.1 JIT · functions | 16,129ᵏ | 12,097ᵏ | 9,252ᵏ | 15,880ᵏ | 11,659ᵏ | 8,948ᵏ |
| .NET 10 · Dapper | 16,053ᵏ | 12,250ᵏ | 9,281 | 15,699ᵏ | 11,662ᵏ | 8,900ᵏ |
| Deno 2.9 | 16,042ᵏ | 12,097ᵏ | 9,310ᵏ | 15,613ᵏ | 11,557ᵏ | 8,809ᵏ |
| NpgsqlRest 4.1 AOT · functions | 16,021ᵏ | 12,050ᵏ | 9,225ᵏ | 15,721ᵏ | 11,660ᵏ | 8,968ᵏ |
| NpgsqlRest 4.1 AOT · SQL files | 15,994ᵏ | 12,035ᵏ | 9,275 | 15,804ᵏ | 11,555ᵏ | 8,924ᵏ |
| .NET 11 · Dapper | 15,947ᵏ | 12,067ᵏ | 9,258 | 15,715ᵏ | 11,579ᵏ | 8,883ᵏ |
| .NET 11 · plain Npgsql | 15,926ᵏ | 12,044ᵏ | 9,302 | 15,570ᵏ | 11,588ᵏ | 8,917ᵏ |
| NpgsqlRest 3.21 JIT · functions | 15,829ᵏ | 11,951ᵏ | 9,236ᵏ | 15,841ᵏ | 11,562ᵏ | 8,897ᵏ |
| NpgsqlRest 3.21 JIT · SQL files | 15,827ᵏ | 11,953ᵏ | 9,420ᵏ | 15,574ᵏ | 11,530ᵏ | 8,886ᵏ |
| NpgsqlRest 3.21 AOT · functions | 15,822ᵏ | 11,988ᵏ | 9,202ᵏ | 15,524ᵏ | 11,564ᵏ | 8,869ᵏ |
| NpgsqlRest 3.21 AOT · SQL files | 15,792ᵏ | 11,932ᵏ | 9,210 | 15,564ᵏ | 11,536ᵏ | 8,839ᵏ |
| Spring Boot 4.2 (Java 25) | 15,766ᵏ | 12,040ᵏ | 9,230 | 15,524ᵏ | 11,592ᵏ | 8,866ᵏ |
| Fastify 5.12 | 14,749 | 11,958ᵏ | 9,243ᵏ | 15,444 | 11,598ᵏ | 8,861ᵏ |
| Express 5.3 | 13,368 | 11,427 | 9,276ᵏ | 14,067 | 11,602ᵏ | 8,851ᵏ |
| NestJS 12.6 | 12,977 | 11,141 | 9,247ᵏ | 13,501 | 11,398 | 8,809ᵏ |
| .NET 11 · EF Core | 10,873 | 9,640 | 8,410 | 11,140 | 10,438 | 8,817ᵏ |
| .NET 10 · EF Core | 10,842 | 9,788 | 8,537 | 10,985 | 10,345 | 8,852 |
| PostgREST 16.6 | 6,267 | 6,170 | 6,044 | 6,186 | 6,213 | 6,178 |
| FastAPI 0.165 † | 3,692 | 3,675 | 3,702 | 3,818 | 3,812 | 3,799 |
| Hasura 2.50 (GraphQL) | 3,543 | 3,552 | 3,438 | 3,206 | 3,148 | 3,110 |
| PostGraphile 5.2 (GraphQL) | 2,640ᵏ | 2,479ᵏ | 2,349ᵏ | 2,714ᵏ | 2,568ᵏ | 2,430ᵏ |
| Django 6.1 † | 2,328 | 2,270 | 2,264 | 2,283 | 2,262 | 2,225 |
| Laravel Octane 13.43 † | 1,723 | 1,721 | 1,708 | 1,720 | 1,703 | 1,702 |
Bold is the best of the column. ᵏ the load generator was out of CPU in that test and the service was not; ᵖ the same for PostgreSQL. † returns JSON columns as a string.
Previous: ← POST Body · Next: Large Payload →