Skip to main content

Database performance across the REST API, the app, Browse, MCP and mocks

Apiome stays fast on large workspaces and large catalogs. Requests run a small, fixed number of database statements, long lists load a page at a time, and queries use their indexes. This post sums up the 27 changes of the database performance work; each has its own entry with the full numbers.

Measured on the scale benchmark database (20,000 projects, 200,000 versions, 1,000,000 classes, 3,100,000 class properties; PostgreSQL 18), before and after:

WhereBeforeAfter
Loading the paths of a 1,000-operation spec4,251 statements, 529 ms6 statements, 27 ms
Loading the properties of a 20,000-class version19,000 statements, 4.6 s1 statement, 0.39 s
Importing a spec in the app19,519 statements, 1.56 s41 statements, 0.66 s
Forking a 20,000-class revision12.3 s2.1 s
Usage ingest, four writers in one workspace1,446 events/s20,772 events/s
Project list, 5,000-project workspace33 ms for every project1.9 ms a page
Deleting one version: the check on its 1,000,000-row classes table26.9 ms0.07 ms
Finding a revision's history among 200,000 versions21.4 ms0.44 ms
Home stat strip counts, 5,000 projectsabout 1.6 sabout 0.4 s, then cached for a minute
MCP Catalog Servers grid, 2,000 servers7.9 s45 ms
MCP catalog tool call, 50 concurrent callers7 statements, 15.5 s p502 statements, 20 ms
MCP spec.get_openapi, 600-operation spec2,705 statements, 141 ms10 statements, 30 ms
Mock request for a cached specan access query and a usage writeno statement
Browse search suggestions0.2–1.2 s a keystroke18–40 ms
Browse "Recently published"13.6 ms0.01 ms

What else changed:

  • Every database statement has a time limit. The REST API, the web app and the browse site stop a statement that runs longer than DB_STATEMENT_TIMEOUT_MS (30 seconds by default).
  • Sign-in and permission checks run in one cached query, and an API key is no longer re-verified with bcrypt on every request.
  • Long lists page with a cursor instead of counting every row. A count that would read every row shows as 10,000+. Some list limits changed; see the REST API changelog.
  • Slow queries are easier to find. Every REST request logs its statement count and time, and the Docker Compose postgres service loads pg_stat_statements and auto_explain.
  • Some answers are cached for a short time: the public directory, MCP catalog analytics and mock specs. A change can take up to the cache time to show.

Upgrading adds indexes and rewrites a few tables. See Upgrade a large database without blocking writes, and Database performance for the settings to size and watch.