payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
23.57k stars 1.5k forks source link

Performance problems with collections listview and api #6888

Closed siccifolium closed 2 months ago

siccifolium commented 3 months ago

Link to reproduction

No response

Describe the Bug

Hey :)

I have a collection with a field of the type blocks. The content we store in this blocks field is quite a lot. So when I query this collection, this takes a lot of time. This is only a problem in the dashboard when displaying the list view of this collection.

The cause for this seems to be that, whenever we load one page of documents from that collection, the complete documents including the big content of the blocks field is loaded.

In most cases this however is not needed: If I have a collection where the content is inside a blocks field and the collection has also a name field, then in the list view in the admin dashboard we only need the name, however the content of the blocks field is also queried which makes loading the list very slow. So we are querying data that we don't need at that moment which leads to performance problems.

So my question would be is there a way to query/load only specific fields of a collection. What I need is something like depth=0 which applies to blocks fields which just delivers the document without the content of the blocks field. Is there a way to somehow achieve this? Can I overwrite an api endpoint and directly work on the database and use a projection or something like this? Could you guide me into the right direction here?

To Reproduce

Create a collection with a blocks field and check the GET Request in the list view in the admin dashboard. For each page every document contains the complete content of the blocks field. As a reference point for the size of our documents: When I query our collection with a page size of 10 then the response is around 60k lines of json where almost most of them belong to the content of the blocks field.

Payload Version

2.8.2

Adapters and Plugins

No response

paulpopus commented 3 months ago

Have you configured https://payloadcms.com/docs/configuration/collections#admin-options the defaultColumns on your collection to get around this?

I think this is saved in the user preferences as well so you'll need to manually choose to hide some columns if you've already modified this.

Does this resolve your issue?

github-actions[bot] commented 3 weeks ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.