PostgreSQL REST API Benchmark, November 2026
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.
Which is the fastest way to put PostgreSQL behind HTTP? 31 services, 1,364 tests, 61 hours of measurement on one 48-core server. Here is the result; everything else in this series explains it.
↑ longer bar is better100% would mean: the fastest service in every test. 50% means: on average, half as fast as the fastest.
- 1Gin 1.12 (Go)93%
- 2Go 1.27 · net/http91%
- 3Bun 1.484%
- 4NpgsqlRest 4.1 JIT · SQL files82%
- 5Deno 2.982%
- 6NpgsqlRest 4.1 JIT · functions79%
- 7NpgsqlRest 3.21 JIT · SQL files77%
- 8.NET 10 · plain Npgsql77%
- 9NpgsqlRest 4.1 AOT · SQL files77%
- 10Axum 0.8 (Rust)76%
- 11.NET 10 · Dapper76%
- 12Actix-web 4.20 (Rust)76%
- 13.NET 11 · plain Npgsql75%
- 14NpgsqlRest 4.1 AOT · functions75%
- 15NpgsqlRest 3.21 JIT · functions75%
- 16.NET 11 · Dapper74%
- 17NpgsqlRest 3.21 AOT · SQL files73%
- 18Swoole 6.2 (PHP)73%
- 19NpgsqlRest 3.21 AOT · functions71%
- 20Fastify 5.1267%
- 21Spring Boot 4.2 (Java 25)61%
- 22NestJS 12.656%
- 23Express 5.356%
- 24.NET 11 · EF Core50%
- 25.NET 10 · EF Core49%
- 26PostgREST 16.633%
- 27FastAPI 0.16529%
- 28Hasura 2.50 (GraphQL)26%
- 29PostGraphile 5.2 (GraphQL)20%
- 30Laravel Octane 13.4320%
- 31Django 6.117%
Find your platform: NpgsqlRest · .NET · Go · Rust · Java · Node.js · Bun and Deno · Python · PHP · PostgREST · GraphQL · or compare any two services.
Every service did the same job in every test: take an HTTP request, call a PostgreSQL function, return JSON. Click a name in the chart to see its code.
What is in this series
The 31 services are hand-written APIs in Go, Rust, .NET, Java, Node.js, Bun, Deno, Python and PHP, and four tools that generate the API from the database (NpgsqlRest, PostgREST, Hasura, PostGraphile). The series measures how many requests each one answers, how long the slow ones take, how much memory and CPU it uses, how long it takes to start, and how much code it needs.
- Overall results: the leaderboard, efficiency, memory, and what limited the tests.
- Find your platform: every service on one page, grouped by platform, with its rank in every kind of test.
- Kinds of test: data types, minimal request, POST body, nested JSON, large payload, many parameters, tables.
- Resources: memory under load and idle, CPU per request, startup time, image size, time in PostgreSQL.
- .NET 10 and .NET 11: what the new runtime changes, and EF Core against Dapper against plain Npgsql.
- NpgsqlRest: version 4.1 against 3.21, AOT against JIT, and against PostgREST, Hasura and PostGraphile.
- Compare any two: pick two services and see them side by side in every test.
- Data and method: the dataset, how to run it yourself, this round against July, and everything that went wrong, in one place.
On every page with charts there is a row of Highlight buttons. Choose your platform once and its bars stay highlighted in every chart of the series. The address of the page changes with what you choose in a chart, so you can copy it and send somebody exactly what you see.
The result in one paragraph
Gin 1.12 (Go) and Go 1.27 · net/http are the fastest, at 93% and 91% of the best possible score. Behind them is a close group: Bun, Deno, NpgsqlRest 4.1, the two Rust services, Swoole, and .NET with plain Npgsql or Dapper, all between 70% and 85%. NpgsqlRest 4.1 is in that group without any endpoint code: its API is generated from PostgreSQL functions or SQL files, and its four variants score 75% to 82%. The other tools that generate an API are far behind: PostgREST 33%, Hasura 26%, PostGraphile 20%. Django and Laravel Octane are last. .NET 11 needs clearly less CPU than .NET 10 for requests that return rows, and is a little slower on tiny ones.
The percentages are a speed score: in every test the fastest service counts as 100%, and a service's score is how close it came to that, averaged over all 44 tests. The full picture.
What was tested
Every service does the same job: accept an HTTP request, call a PostgreSQL function, return the result as JSON. All services call the same functions in the same database, so what differs between them is the service: its runtime, its framework, its database driver, and how it turns rows into a response.
Nine kinds of test, each at several load levels and sizes, 44 tests per service:
| Kind of test | What the service does | Users at the same time | Tests |
|---|---|---|---|
| Data types | Rows with 23 columns of every common PostgreSQL type, 16 typed parameters. 1, 10, 100 and 500 rows. | 1, 50, 100, 200 | 16 |
| Minimal request | One tiny row, no parameters: the cost of a request before any work. | 100, 200, 500 | 3 |
| POST body | A JSON body in, rows that echo it out. | 50, 100, 200 | 6 |
| Nested JSON | 100 rows with a JSON object nested 1 to 3 levels deep. | 50, 100 | 6 |
| Large payload | One response of 100 KB or 500 KB. | 25, 50 | 4 |
| Many parameters | Twenty typed parameters in the query string. | 50, 100, 200 | 3 |
| Table lookup | One row by primary key from a table of 500,000 rows. | 50, 200 | 2 |
| Table list page | A page of 20 rows through an index. | 50, 200 | 2 |
| Table insert | An insert that returns the new row. | 50, 200 | 2 |
The first six use functions that compute their result in memory, which keeps the database's part constant and isolates the service. The three table tests are new in this round: they read and write real tables, which is what most endpoints of a real API do.
The 31 services
Every name above links to the code that ran. Each service is in its own directory in the repository, with a Dockerfile, at the version named. The whole source of a hand-written service is one file of 100 to 400 lines; for the generated APIs it is a configuration file of 12 to 86 lines (the counts). Read them, compare them, and if one is set up unfairly or could be written better, open a pull request: the next round runs whatever is in the repository. The scorecard page lists all of them in one table, and anyone can run the round.
Three groups in this lineup are worth a word:
- Generated APIs. NpgsqlRest, PostgREST, Hasura and PostGraphile need no endpoint code. They are compared with each other and with the hand-written services on equal terms: the same functions, the same requests.
- GraphQL. Hasura and PostGraphile answer the same nine operations over GraphQL, as a
POSTwith a query document and variables. It is the same data, asked for the way those products are used. - Pairs. .NET 10 and .NET 11 run the same source code. NpgsqlRest 3.21 and 4.1 are the previous and the current version. Go and Gin, Actix-web and Axum, Express, Fastify and NestJS, Bun and Deno, Swoole and Laravel Octane share a language and a driver, so each pair shows what the framework costs.
How it was tested
One server, three roles, separate cores. A Hetzner CCX63 with 48 dedicated vCPUs (AMD EPYC-Milan Processor) and 192 GB of memory, Ubuntu 26.04.1 LTS, PostgreSQL 19.0, k6 2.4.0. Each role is pinned to its own cores:
| Role | CPU cores |
|---|---|
| PostgreSQL | 16 |
| The load generator (k6) | 12 |
| The service under test | 4 |
| Operating system, Docker, the resource collector | 16 |
The service gets 4 cores, as in the previous round. PostgreSQL and the load generator get far more than they got then (2 each), for a reason: a benchmark measures whichever part runs out first. With 2 cores, the database ran out before the service in almost every test of July. The aim of this split is that the service is the part that runs out.
One service at a time. The 31 services are all started, and all but the one under test are paused. Each test is: a 10-second warm-up of the same test that is not measured, a 10-second ramp to the target number of users at the same time, a hold of 60 seconds (30 in the minimal request test), and a 30-second pause. 1,364 tests took 60.7 hours.
The same resources for every service. About 100 database connections per service (Laravel Octane has one per worker, which is how it works). Services that run one process per CPU core run 4. No service has a cache in front of it.
Everything is measured, every second. CPU and memory of the service, of PostgreSQL and of the load generator, from the kernel's own counters. PostgreSQL counts the statements of each test and the time it spent on them. Each service's startup time, idle memory and image size were measured before the first test.
For every test, the report says what was out of CPU. The service was in 558 of 1,364 tests, the load generator in 380, PostgreSQL in 55, and nothing in 371. A throughput number says how much a service can carry only in the first group. The charts mark results where the load generator or PostgreSQL was the limit and the service was not. More on this.
What to keep in mind
A benchmark is a measurement of one setup. These are the things about this one that a careful reader should know. They are also listed, with the evidence, on the data and method page.
- The author of NpgsqlRest runs this benchmark. That is a conflict of interest, and the answer to it is that the code of every service, the test scripts, the raw data of every test and the script that produced these pages are public. If a service is set up badly, a pull request fixes it for the next round.
- 193 of the 1,364 tests were run twice. During the first run PostgreSQL ran out of connection slots: the limit was set for the 20 services of the previous round, and 31 services hold more connections than that. The tests that ran while connections were being refused were repeated on the same server with a higher limit, and the repeated results are the ones used. The original results are in the dataset.
- The load generator was the limit in 27% of the tests. Even with 12 cores, parsing and checking large responses costs k6 more than producing them costs a fast service. Those results are marked, and they understate the fastest services.
- Eight services return JSON columns as strings in two kinds of test (POST body, nested JSON), which is less work than returning nested JSON. They did the same in July. It is left as it was and marked in the tables (issue 9).
- Two services were set up wrongly in the first run and were corrected. PostgREST had 10 database connections instead of 100, and the Swoole service answered four requests at a time. Both were fixed, and all 88 of their tests were run again on a second server of the same type; two unchanged services ran with them and came out within 2% of their first numbers. The pages show the corrected results (what happened).
- The two Rust services build their SQL as text instead of preparing statements with parameters. A Rust service written for speed would prepare them (issue 10).
- Every test ran once. There is no measure of run-to-run noise; treat differences of a few percent as a tie.
- Latency is measured in a closed loop: a slow service is sent fewer requests. Compare latency between services with similar throughput.
- 10 tests missed their latency objective, and in none did more than 1% of the requests fail.
The series
- Overall Results
- Data Types
- Minimal Request
- POST Body
- Nested JSON
- Large Payload
- Many Parameters
- Tables
- Resources
- Every Service, One Scorecard
- .NET 10 and .NET 11
- NpgsqlRest
- Compare Any Two
- Data and Method
Source and data: the benchmark repository, branch 202611241439 · the report generated with the round · the dataset
Earlier rounds: July 2026 · January 2026 · 2025
Next: Overall Results →