Open
Description
Describe the Bug
When creating a lot of blocks and using them in a GlobalConfig with postgreSQL, the query gets really slow.
Using those same blocks in a collections stays fast.
Here is an example using the global, it takes more than 1 second on average. This number grows the more blocks are added, in my project where i noticed this it is up to 2.5 seconds.

Using the exact same setup, but within a collection, suddenly the API call only takes 50ms on average.

The setup for the global and collection are basically exactly the same, for more details look in the reproduction repo


I don't think I am doing anything wrong, but I am not that familiar with PayloadCMS as it is my first project in it.
Link to the code that reproduces this issue
https://github.com/Robbe95/payload-slow-global
Reproduction Steps
- Setup local postgreSQL server
- Setup .env with
DATABASE_URI
andPAYLOAD_SECRET
- Run the server
- Add a complex blocks structure, see https://github.com/Robbe95/payload-slow-global/blob/main/src/blocks/testBlocks.ts
- Make a pages collection and add the blocks structure
- Make a global collection and add the blocks structure
- Run the API call http://localhost:3000/api/pages/1
- Run the API call http://localhost:3000/api/globals/home-page
- Notice the speed difference
Which area(s) are affected? (Select all that apply)
db-postgres
Environment Info
Binaries:
Node: 22.6.0
npm: 10.8.2
Yarn: N/A
pnpm: 9.15.4
Relevant Packages:
payload: 3.17.1
next: 15.1.0
@payloadcms/db-postgres: 3.17.1
@payloadcms/email-nodemailer: 3.17.1
@payloadcms/graphql: 3.17.1
@payloadcms/next/utilities: 3.17.1
@payloadcms/payload-cloud: 3.17.1
@payloadcms/richtext-lexical: 3.17.1
@payloadcms/translations: 3.17.1
@payloadcms/ui/shared: 3.17.1
react: 19.0.0
react-dom: 19.0.0
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:12 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6020
Available memory (MB): 32768
Available CPU cores: 10