Skip to content

Speed

What a lookup, a save and a move cost, in queries and in milliseconds on a database with 100,000 documents.

The package tests count the queries a lookup runs, on MongoDB, Postgres and SQLite, so a change that adds one fails a test.

Operation What the plugin adds
findByPath One indexed query per collection, run at the same time. None for a path with a reserved segment

On Postgres and SQLite with localization, Payload reads the document findByPath found in a second statement.

A save reads the document before and after its write. A move reads the documents below it 1,000 at a time, and then reads each one again right before it rewrites it. No test counts the queries of a save or a move.

A save runs its queries one at a time, as MongoDB requires inside a transaction.

The median and 95th percentile of each, on 100,000 documents. Run on 2026-11-19, on Apple M3 Max with 128 GB of memory and Node 26.13.1.

Without localization
OperationMongoDBPostgresSQLite
Lookup by path0.3 ms (p95 0.5 ms)0.5 ms (p95 0.6 ms)0.3 ms (p95 0.4 ms)
Autosave9.1 ms (p95 13 ms)4.6 ms (p95 5.8 ms)50 ms (p95 55 ms)
Publish, same slug9.2 ms (p95 13 ms)4.5 ms (p95 5.1 ms)28 ms (p95 32 ms)
Publish, new slug11 ms (p95 14 ms)5.9 ms (p95 6.7 ms)29 ms (p95 34 ms)
Move of 1,000 pages892 ms (p95 1.1 s)2.2 s (p95 2.3 s)1.9 s (p95 1.9 s)
With localization (two locales)
OperationMongoDBPostgresSQLite
Lookup by path0.2 ms (p95 0.4 ms)0.7 ms (p95 1 ms)0.3 ms (p95 0.4 ms)
Autosave9.4 ms (p95 13 ms)4.9 ms (p95 5.5 ms)45 ms (p95 51 ms)
Publish, same slug10 ms (p95 13 ms)5.9 ms (p95 6.4 ms)26 ms (p95 30 ms)
Publish, new slug11 ms (p95 14 ms)7.7 ms (p95 11 ms)27 ms (p95 33 ms)
Move of 1,000 pages924 ms (p95 1 s)3.3 s (p95 3.4 s)2.2 s (p95 2.3 s)

This compares path with two other ways a site finds a page by its URL and moves a branch:

  • Nested docs: Payload’s @payloadcms/plugin-nested-docs, which stores each page’s breadcrumbs, the URL and title of every page above it and its own.
  • Slug by slug: pages with only a slug and a parent, and no plugin. A lookup asks for each segment in turn.

Nested docs and slug by slug each get a copy of the benchmark’s pages, the same tree with the same versions and drafts, on the same machine and databases. The comparison runs without localization.

  • path
  • nested docs
  • slug by slug
MongoDB0 ms1 ms2 ms3 ms1310 path, 1 segment: 0.2 ms (p95 0.3 ms) path, 3 segments: 0.2 ms (p95 0.3 ms) path, 10 segments: 0.2 ms (p95 0.3 ms) nested docs, 1 segment: 1.7 ms (p95 1.9 ms) nested docs, 3 segments: 1.7 ms (p95 1.9 ms) nested docs, 10 segments: 1.7 ms (p95 2.1 ms) slug by slug, 1 segment: 0.2 ms (p95 0.2 ms) slug by slug, 3 segments: 0.4 ms (p95 0.6 ms) slug by slug, 10 segments: 1.4 ms (p95 1.7 ms) 1.7 ms1.4 ms0.2 msPostgres0 ms1 ms2 ms3 ms1310 path, 1 segment: 0.4 ms (p95 0.5 ms) path, 3 segments: 0.4 ms (p95 0.5 ms) path, 10 segments: 0.4 ms (p95 0.5 ms) nested docs, 1 segment: 0.6 ms (p95 0.7 ms) nested docs, 3 segments: 0.8 ms (p95 0.9 ms) nested docs, 10 segments: 0.7 ms (p95 0.8 ms) slug by slug, 1 segment: 0.3 ms (p95 0.3 ms) slug by slug, 3 segments: 0.8 ms (p95 0.9 ms) slug by slug, 10 segments: 2.7 ms (p95 2.9 ms) 2.7 ms0.7 ms0.4 msSQLite0 ms1 ms2 ms3 ms1310 path, 1 segment: 0.3 ms (p95 0.4 ms) path, 3 segments: 0.3 ms (p95 0.4 ms) path, 10 segments: 0.3 ms (p95 0.4 ms) nested docs, 1 segment: 0.4 ms (p95 0.4 ms) nested docs, 3 segments: 0.4 ms (p95 0.5 ms) nested docs, 10 segments: 0.4 ms (p95 0.5 ms) slug by slug, 1 segment: 0.2 ms (p95 0.2 ms) slug by slug, 3 segments: 0.5 ms (p95 0.5 ms) slug by slug, 10 segments: 1.7 ms (p95 2.1 ms) 1.7 ms0.4 ms0.3 ms
The median of 1,000 lookups of the same page, by how many segments its path has.
The numbers
MethodSegmentsMongoDBPostgresSQLite
path10.2 ms (p95 0.3 ms)0.4 ms (p95 0.5 ms)0.3 ms (p95 0.4 ms)
path30.2 ms (p95 0.3 ms)0.4 ms (p95 0.5 ms)0.3 ms (p95 0.4 ms)
path100.2 ms (p95 0.3 ms)0.4 ms (p95 0.5 ms)0.3 ms (p95 0.4 ms)
nested docs11.7 ms (p95 1.9 ms)0.6 ms (p95 0.7 ms)0.4 ms (p95 0.4 ms)
nested docs31.7 ms (p95 1.9 ms)0.8 ms (p95 0.9 ms)0.4 ms (p95 0.5 ms)
nested docs101.7 ms (p95 2.1 ms)0.7 ms (p95 0.8 ms)0.4 ms (p95 0.5 ms)
slug by slug10.2 ms (p95 0.2 ms)0.3 ms (p95 0.3 ms)0.2 ms (p95 0.2 ms)
slug by slug30.4 ms (p95 0.6 ms)0.8 ms (p95 0.9 ms)0.5 ms (p95 0.5 ms)
slug by slug101.4 ms (p95 1.7 ms)2.7 ms (p95 2.9 ms)1.7 ms (p95 2.1 ms)

The pages are a top-level page with 100 pages below it, a page three levels down and the last of a line of ten.

Slug by slug runs one query per segment, each on its index on slug and parent, so it takes longer the deeper a page sits.

  • path
  • nested docs
MongoDB10 ms100 ms1 s10 s91001,000 path, 9 pages below: 17 ms (p95 34 ms), 20 runs path, 100 pages below: 93 ms (p95 109 ms), 20 runs path, 1,000 pages below: 892 ms (p95 1.1 s), 5 runs nested docs, 9 pages below: 75 ms (p95 112 ms), 20 runs nested docs, 100 pages below: 766 ms (p95 1.2 s), 20 runs nested docs, 1,000 pages below: 7.2 s (p95 7.5 s), 5 runs 7.2 s892 msPostgres10 ms100 ms1 s10 s91001,000 path, 9 pages below: 33 ms (p95 42 ms), 20 runs path, 100 pages below: 271 ms (p95 665 ms), 20 runs path, 1,000 pages below: 2.2 s (p95 2.3 s), 5 runs nested docs, 9 pages below: 64 ms (p95 74 ms), 20 runs nested docs, 100 pages below: 748 ms (p95 993 ms), 20 runs nested docs, 1,000 pages below: 8.2 s (p95 8.9 s), 5 runs 8.2 s2.2 sSQLite10 ms100 ms1 s10 s91001,000 path, 9 pages below: 28 ms (p95 55 ms), 20 runs path, 100 pages below: 193 ms (p95 216 ms), 20 runs path, 1,000 pages below: 1.9 s (p95 1.9 s), 5 runs nested docs, 9 pages below: 43 ms (p95 46 ms), 20 runs nested docs, 100 pages below: 404 ms (p95 421 ms), 20 runs nested docs, 1,000 pages below: 4.1 s (p95 4.2 s), 5 runs 4.1 s1.9 s
The median of 20, 20 and 5 renames of a page, by how many pages sit below it. Both scales are logarithmic.
The numbers
MethodPages belowRunsMongoDBPostgresSQLite
path92017 ms (p95 34 ms)33 ms (p95 42 ms)28 ms (p95 55 ms)
path1002093 ms (p95 109 ms)271 ms (p95 665 ms)193 ms (p95 216 ms)
path1,0005892 ms (p95 1.1 s)2.2 s (p95 2.3 s)1.9 s (p95 1.9 s)
nested docs92075 ms (p95 112 ms)64 ms (p95 74 ms)43 ms (p95 46 ms)
nested docs10020766 ms (p95 1.2 s)748 ms (p95 993 ms)404 ms (p95 421 ms)
nested docs1,00057.2 s (p95 7.5 s)8.2 s (p95 8.9 s)4.1 s (p95 4.2 s)

Both take longer the more pages a branch holds. Path writes each page below once, and its latest version once. Nested docs saves each page below in full, with its hooks, validation and a new version. A slug-by-slug site has nothing to move, since the pages below keep their parent.

path nested docs slug by slug
Find a page by URL findByPath, one query on path per collection, run at once No lookup of its own. A query on breadcrumbs.url also matches every page below, so the site picks the page whose last breadcrumb is the URL One query per segment, by slug and the parent found before
Index the lookup uses path, which the plugin indexes None. breadcrumbs.url has no index One on slug and parent, which the site adds
A move One write for each page below, and one for its latest version A full save of each page below, with hooks, validation and a new version, which reads every page above it once more One save of the page
A new page One save Two saves: the plugin saves the page again to name it in its own breadcrumbs One save
Refuses a taken path Yes, and names the document that is there No No
  • Nested docs runs as its docs set it up, with generateURL joining the slugs into each URL. Without it, breadcrumbs.url stays empty. It adds no index.
  • Its lookup also matches the slug. Without it, a top-level page’s query returns its whole branch.
  • On MongoDB nothing indexes nested docs’ parent, which each save of a page below queries twice. Postgres and SQLite index it, as Payload indexes a relationship column there.
  • findByPath looks in posts too, at the same time. The other two look in pages only.
  • Slug by slug uses an index on slug and parent that the site adds itself.
  • The copies hold the pages only, about 2,000 each. A collection with more pages makes nested docs’ unindexed lookup slower.
cd packages/path && bun run bench

It starts its own databases, seeds them and prints these tables, which takes about an hour, mostly seeding. That full run then writes its numbers to apps/docs/src/data/path-speed.json, which the tables and charts on this page read, and to the table in the package’s README. A smaller run, such as BENCH_DOCUMENTS=4000 bun run bench, only prints them.