Skip to content

Nested JSON: Objects Inside Objects ​

Benchmark · November 2026 · Nested JSON

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.
Highlight:

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.

Users at the same time
Levels of nesting
Show
Requests per second: 50 users, 1 levels

↑ longer bar is betterHow many requests each service answered per second, with 50 users sending requests at the same time.

  1. 1Go 1.27 · net/http20,264req/sk6 limit
  2. 2Gin 1.12 (Go)19,865req/s
  3. 3Axum 0.8 (Rust)16,355req/sk6 limit
  4. 4Bun 1.416,267req/sk6 limit
  5. 5Actix-web 4.20 (Rust)16,231req/sk6 limit
  6. 6NpgsqlRest 4.1 JIT · SQL files16,220req/sk6 limit
  7. 7.NET 10 · plain Npgsql16,206req/sk6 limit
  8. 8Swoole 6.2 (PHP)16,160req/s
  9. 9NpgsqlRest 4.1 JIT · functions16,129req/sk6 limit
  10. 10.NET 10 · Dapper16,053req/sk6 limit
  11. 11Deno 2.916,042req/sk6 limit
  12. 12NpgsqlRest 4.1 AOT · functions16,021req/sk6 limit
  13. 13NpgsqlRest 4.1 AOT · SQL files15,994req/sk6 limit
  14. 14.NET 11 · Dapper15,947req/sk6 limit
  15. 15.NET 11 · plain Npgsql15,926req/sk6 limit
  16. 16NpgsqlRest 3.21 JIT · functions15,829req/sk6 limit
  17. 17NpgsqlRest 3.21 JIT · SQL files15,827req/sk6 limit
  18. 18NpgsqlRest 3.21 AOT · functions15,822req/sk6 limit
  19. 19NpgsqlRest 3.21 AOT · SQL files15,792req/sk6 limit
  20. 20Spring Boot 4.2 (Java 25)15,766req/sk6 limit
  21. 21Fastify 5.1214,749req/s
  22. 22Express 5.313,368req/s
  23. 23NestJS 12.612,977req/s
  24. 24.NET 11 · EF Core10,873req/s
  25. 25.NET 10 · EF Core10,842req/s
  26. 26PostgREST 16.66,267req/s
  27. 27FastAPI 0.1653,692req/s
  28. 28Hasura 2.50 (GraphQL)3,543req/s
  29. 29PostGraphile 5.2 (GraphQL)2,640req/sk6 limit
  30. 30Django 6.12,328req/s
  31. 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.

PlatformIts fastest servicePlace among the 31Requests per secondCompared with the fastestIts code
GoGo 1.27 · net/http120,264100%main.go
RustAxum 0.8 (Rust)316,35581%main.rs
Bun & DenoBun 1.4416,26780%app.ts
NpgsqlRestNpgsqlRest 4.1 JIT · SQL files616,22080%appsettings.json
.NET.NET 10 · plain Npgsql716,20680%Program.cs
PHPSwoole 6.2 (PHP)816,16080%server.php
JavaSpring Boot 4.2 (Java 25)2015,76678%Application.java
Node.jsFastify 5.122114,74973%app.js
PostgRESTPostgREST 16.6266,26731%postgrest.conf
PythonFastAPI 0.165273,69218%app.py
GraphQLHasura 2.50 (GraphQL)283,54317%databases.yaml

Every measurement of the main test ​

Latency, CPU, memory and time in PostgreSQL for all 31 services
#ServiceRequests/sMedian msp99 msCPU cores usedRequests/s per corePeak memory MBTime in PostgreSQLOut of CPU
1Go 1.27 · net/http †20,2641.416.22.727,4433211%k6
2Gin 1.12 (Go) †19,8651.466.32.787,1573411%—
3Axum 0.8 (Rust)16,3551.567.42.775,901196%k6
4Bun 1.416,2671.617.62.566,36416110%k6
5Actix-web 4.20 (Rust)16,2311.657.72.745,920296%k6
6NpgsqlRest 4.1 JIT · SQL files16,2201.607.12.197,42111911%k6
7.NET 10 · plain Npgsql16,2061.587.23.155,1461035%k6
8Swoole 6.2 (PHP) †16,1602.366.33.534,582814%service
9NpgsqlRest 4.1 JIT · functions16,1291.607.22.197,36112410%k6
10.NET 10 · Dapper16,0531.657.13.105,1841025%k6
11Deno 2.916,0421.727.82.705,93929910%k6
12NpgsqlRest 4.1 AOT · functions16,0211.657.32.476,4865410%k6
13NpgsqlRest 4.1 AOT · SQL files15,9941.667.22.456,5355711%k6
14.NET 11 · Dapper15,9471.697.42.536,3131135%k6
15.NET 11 · plain Npgsql15,9261.707.42.346,8101175%k6
16NpgsqlRest 3.21 JIT · functions15,8291.717.43.135,06213010%k6
17NpgsqlRest 3.21 JIT · SQL files15,8271.727.23.005,27213711%k6
18NpgsqlRest 3.21 AOT · functions15,8221.727.32.825,6067910%k6
19NpgsqlRest 3.21 AOT · SQL files15,7921.737.32.795,6549211%k6
20Spring Boot 4.2 (Java 25)15,7661.747.82.925,3921,25010%k6
21Fastify 5.1214,7492.227.53.274,5134079%—
22Express 5.313,3682.787.33.603,7114438%service
23NestJS 12.612,9772.967.13.623,5815068%service
24.NET 11 · EF Core10,8733.448.53.662,9711603%service
25.NET 10 · EF Core10,8423.547.83.822,8371493%service
26PostgREST 16.66,2677.099.72.962,120733%—
27FastAPI 0.165 †3,69212.1215.53.839642120%service
28Hasura 2.50 (GraphQL)3,54313.2217.92.391,4822123%—
29PostGraphile 5.2 (GraphQL)2,6403.1231.52.081,2678444%k6
30Django 6.1 †2,32819.1835.63.456744011%service
31Laravel Octane 13.43 †1,72323.9751.83.824507581%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.

Service50 users, depth 150 users, depth 250 users, depth 3100 users, depth 1100 users, depth 2100 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,86518,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.416,267ᵏ12,206ᵏ9,303ᵏ15,807ᵏ11,641ᵏ8,917ᵏ
Actix-web 4.20 (Rust)16,231ᵏ12,206ᵏ9,28615,905ᵏ11,685ᵏ8,932ᵏ
NpgsqlRest 4.1 JIT · SQL files16,220ᵏ12,153ᵏ9,22415,669ᵏ11,582ᵏ8,897ᵏ
.NET 10 · plain Npgsql16,206ᵏ12,087ᵏ9,30715,673ᵏ11,493ᵏ8,890ᵏ
Swoole 6.2 (PHP) †16,16015,58214,82616,68716,32415,542
NpgsqlRest 4.1 JIT · functions16,129ᵏ12,097ᵏ9,252ᵏ15,880ᵏ11,659ᵏ8,948ᵏ
.NET 10 · Dapper16,053ᵏ12,250ᵏ9,28115,699ᵏ11,662ᵏ8,900ᵏ
Deno 2.916,042ᵏ12,097ᵏ9,310ᵏ15,613ᵏ11,557ᵏ8,809ᵏ
NpgsqlRest 4.1 AOT · functions16,021ᵏ12,050ᵏ9,225ᵏ15,721ᵏ11,660ᵏ8,968ᵏ
NpgsqlRest 4.1 AOT · SQL files15,994ᵏ12,035ᵏ9,27515,804ᵏ11,555ᵏ8,924ᵏ
.NET 11 · Dapper15,947ᵏ12,067ᵏ9,25815,715ᵏ11,579ᵏ8,883ᵏ
.NET 11 · plain Npgsql15,926ᵏ12,044ᵏ9,30215,570ᵏ11,588ᵏ8,917ᵏ
NpgsqlRest 3.21 JIT · functions15,829ᵏ11,951ᵏ9,236ᵏ15,841ᵏ11,562ᵏ8,897ᵏ
NpgsqlRest 3.21 JIT · SQL files15,827ᵏ11,953ᵏ9,420ᵏ15,574ᵏ11,530ᵏ8,886ᵏ
NpgsqlRest 3.21 AOT · functions15,822ᵏ11,988ᵏ9,202ᵏ15,524ᵏ11,564ᵏ8,869ᵏ
NpgsqlRest 3.21 AOT · SQL files15,792ᵏ11,932ᵏ9,21015,564ᵏ11,536ᵏ8,839ᵏ
Spring Boot 4.2 (Java 25)15,766ᵏ12,040ᵏ9,23015,524ᵏ11,592ᵏ8,866ᵏ
Fastify 5.1214,74911,958ᵏ9,243ᵏ15,44411,598ᵏ8,861ᵏ
Express 5.313,36811,4279,276ᵏ14,06711,602ᵏ8,851ᵏ
NestJS 12.612,97711,1419,247ᵏ13,50111,3988,809ᵏ
.NET 11 · EF Core10,8739,6408,41011,14010,4388,817ᵏ
.NET 10 · EF Core10,8429,7888,53710,98510,3458,852
PostgREST 16.66,2676,1706,0446,1866,2136,178
FastAPI 0.165 †3,6923,6753,7023,8183,8123,799
Hasura 2.50 (GraphQL)3,5433,5523,4383,2063,1483,110
PostGraphile 5.2 (GraphQL)2,640ᵏ2,479ᵏ2,349ᵏ2,714ᵏ2,568ᵏ2,430ᵏ
Django 6.1 †2,3282,2702,2642,2832,2622,225
Laravel Octane 13.43 †1,7231,7211,7081,7201,7031,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 →

Comments