Speed
What a lookup, a save and a move cost, in queries and in milliseconds on a database with 100,000 documents.
In queries
Section titled “In queries”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.
In milliseconds
Section titled “In milliseconds”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.
| Operation | MongoDB | Postgres | SQLite |
|---|---|---|---|
| Lookup by path | 0.3 ms (p95 0.5 ms) | 0.5 ms (p95 0.6 ms) | 0.3 ms (p95 0.4 ms) |
| Autosave | 9.1 ms (p95 13 ms) | 4.6 ms (p95 5.8 ms) | 50 ms (p95 55 ms) |
| Publish, same slug | 9.2 ms (p95 13 ms) | 4.5 ms (p95 5.1 ms) | 28 ms (p95 32 ms) |
| Publish, new slug | 11 ms (p95 14 ms) | 5.9 ms (p95 6.7 ms) | 29 ms (p95 34 ms) |
| Move of 1,000 pages | 892 ms (p95 1.1 s) | 2.2 s (p95 2.3 s) | 1.9 s (p95 1.9 s) |
| Operation | MongoDB | Postgres | SQLite |
|---|---|---|---|
| Lookup by path | 0.2 ms (p95 0.4 ms) | 0.7 ms (p95 1 ms) | 0.3 ms (p95 0.4 ms) |
| Autosave | 9.4 ms (p95 13 ms) | 4.9 ms (p95 5.5 ms) | 45 ms (p95 51 ms) |
| Publish, same slug | 10 ms (p95 13 ms) | 5.9 ms (p95 6.4 ms) | 26 ms (p95 30 ms) |
| Publish, new slug | 11 ms (p95 14 ms) | 7.7 ms (p95 11 ms) | 27 ms (p95 33 ms) |
| Move of 1,000 pages | 924 ms (p95 1 s) | 3.3 s (p95 3.4 s) | 2.2 s (p95 2.3 s) |
Compared with
Section titled “Compared with”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’sbreadcrumbs, 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.
Finding a page
Section titled “Finding a page”- path
- nested docs
- slug by slug
The numbers
| Method | Segments | MongoDB | Postgres | SQLite |
|---|---|---|---|---|
| path | 1 | 0.2 ms (p95 0.3 ms) | 0.4 ms (p95 0.5 ms) | 0.3 ms (p95 0.4 ms) |
| path | 3 | 0.2 ms (p95 0.3 ms) | 0.4 ms (p95 0.5 ms) | 0.3 ms (p95 0.4 ms) |
| path | 10 | 0.2 ms (p95 0.3 ms) | 0.4 ms (p95 0.5 ms) | 0.3 ms (p95 0.4 ms) |
| nested docs | 1 | 1.7 ms (p95 1.9 ms) | 0.6 ms (p95 0.7 ms) | 0.4 ms (p95 0.4 ms) |
| nested docs | 3 | 1.7 ms (p95 1.9 ms) | 0.8 ms (p95 0.9 ms) | 0.4 ms (p95 0.5 ms) |
| nested docs | 10 | 1.7 ms (p95 2.1 ms) | 0.7 ms (p95 0.8 ms) | 0.4 ms (p95 0.5 ms) |
| slug by slug | 1 | 0.2 ms (p95 0.2 ms) | 0.3 ms (p95 0.3 ms) | 0.2 ms (p95 0.2 ms) |
| slug by slug | 3 | 0.4 ms (p95 0.6 ms) | 0.8 ms (p95 0.9 ms) | 0.5 ms (p95 0.5 ms) |
| slug by slug | 10 | 1.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.
Moving a branch
Section titled “Moving a branch”- path
- nested docs
The numbers
| Method | Pages below | Runs | MongoDB | Postgres | SQLite |
|---|---|---|---|---|---|
| path | 9 | 20 | 17 ms (p95 34 ms) | 33 ms (p95 42 ms) | 28 ms (p95 55 ms) |
| path | 100 | 20 | 93 ms (p95 109 ms) | 271 ms (p95 665 ms) | 193 ms (p95 216 ms) |
| path | 1,000 | 5 | 892 ms (p95 1.1 s) | 2.2 s (p95 2.3 s) | 1.9 s (p95 1.9 s) |
| nested docs | 9 | 20 | 75 ms (p95 112 ms) | 64 ms (p95 74 ms) | 43 ms (p95 46 ms) |
| nested docs | 100 | 20 | 766 ms (p95 1.2 s) | 748 ms (p95 993 ms) | 404 ms (p95 421 ms) |
| nested docs | 1,000 | 5 | 7.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.
What each does
Section titled “What each does”| 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 |
What favours which
Section titled “What favours which”- Nested docs runs as its docs set it up, with
generateURLjoining the slugs into each URL. Without it,breadcrumbs.urlstays 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. findByPathlooks 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.
Run it yourself
Section titled “Run it yourself”cd packages/path && bun run benchIt 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.