From ed406b1b14b1aeff8fcd8706e07d75bcee758d25 Mon Sep 17 00:00:00 2001 From: Paul Popus Date: Mon, 28 Apr 2025 22:13:35 +0100 Subject: [PATCH 1/2] docs: add pagination and limit: 0 information in pagination for API docs --- docs/queries/pagination.mdx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/queries/pagination.mdx b/docs/queries/pagination.mdx index e3549d5f3ad..1f4c688f7d1 100644 --- a/docs/queries/pagination.mdx +++ b/docs/queries/pagination.mdx @@ -55,10 +55,11 @@ All collection `find` queries are paginated automatically. Responses are returne All Payload APIs support the pagination controls below. With them, you can create paginated lists of documents within your application: -| Control | Description | -| ------- | --------------------------------------- | -| `limit` | Limits the number of documents returned | -| `page` | Get a specific page number | +| Control | Default | Description | +| ------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `limit` | `10` | Limits the number of documents returned per page - set to `0` to show all documents, we recommend `pagination: false` alongside with this in order to improve performance of returning all documents | +| `pagination` | `true` | Set to `false` to disable pagination and return all documents | +| `page` | `1` | Get a specific page number | ### Disabling pagination within Local API From 3f6d375a353386211250ff5620fbf3ca7e47820a Mon Sep 17 00:00:00 2001 From: Paul Popus Date: Tue, 29 Apr 2025 15:29:40 +0100 Subject: [PATCH 2/2] add explanation --- docs/queries/pagination.mdx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/queries/pagination.mdx b/docs/queries/pagination.mdx index 1f4c688f7d1..81c10a61e66 100644 --- a/docs/queries/pagination.mdx +++ b/docs/queries/pagination.mdx @@ -64,3 +64,9 @@ All Payload APIs support the pagination controls below. With them, you can creat ### Disabling pagination within Local API For `find` operations within the Local API, you can disable pagination to retrieve all documents from a collection by passing `pagination: false` to the `find` local operation. + +### Difference between `limit: 0` and `pagination: false` + +While you may get the same results when passing just `limit: 0`, the actual logic of pagination is separate and is still being run unless you use `pagination: false`, instead you just get all the results on page 1. + +For optimization, we recommend using `limit: 0` with `pagination: false` to avoid running the pagination logic. This is especially important when using `find` with a large number of documents, as it can significantly improve performance.