-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Describe the Bug
We’re encountering a PostgreSQL error when working with a Payload CMS instance that has more than 100 collections.
🐞 Bug
Payload internally uses a table called payload_locked_documents_rels to manage document locking. This table has one column per collection. When the number of collections exceeds a certain threshold (around 100), PostgreSQL throws an error when trying to edit a document. The issue seems to stem from how the locking mechanism constructs a SQL query that touches all those columns, resulting in a statement that is too large or exceeds PostgreSQL’s limits.
ERROR: cannot pass more than 100 arguments to a function
err: (
"type": "DatabaseError",
"message": "cannot pass
more than 100 arguments to a
function"
"stack":
error: cannot pass more than 100 arguments to a function
Link to the code that reproduces this issue
https://github.com/andyLyon-212/payload-cms-100-collections-reproduction
Reproduction Steps
📋 Steps to Reproduce
1. Create 100+ collections in a Payload project.
2. Attempt to edit a document from one of the collections.
3. Payload triggers a lock via the payload_locked_documents_rels table.
4. PostgreSQL throws an error (e.g., query too long, too many columns, etc.).
Which area(s) are affected? (Select all that apply)
db-postgres
Environment Info
Binaries:
Node: 20.19.3
npm: 10.8.2
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
payload: 3.46.0
next: 15.3.3
@payloadcms/db-postgres: 3.46.0
@payloadcms/email-nodemailer: 3.46.0
@payloadcms/graphql: 3.46.0
@payloadcms/live-preview: 3.46.0
@payloadcms/live-preview-react: 3.46.0
@payloadcms/next/utilities: 3.46.0
@payloadcms/payload-cloud: 3.46.0
@payloadcms/plugin-form-builder: 3.46.0
@payloadcms/plugin-nested-docs: 3.46.0
@payloadcms/plugin-redirects: 3.46.0
@payloadcms/plugin-search: 3.46.0
@payloadcms/plugin-seo: 3.46.0
@payloadcms/richtext-lexical: 3.46.0
@payloadcms/translations: 3.46.0
@payloadcms/ui/shared: 3.46.0
react: 19.1.0
react-dom: 19.1.0
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:48:46 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8103
Available memory (MB): 16384
Available CPU cores: 8