You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bulk delete fails on Cloudflare D1 with "too many SQL variables" (document lock query binds collections × ids parameters) #19233
Deleting a handful of documents at once (e.g. selecting several rows in the list view) fails on Cloudflare D1 with too many SQL variables.
The lock handling of bulk operations (getLockedDocumentIds/deleteDocumentLocks in packages/payload/src/utilities/checkDocumentLockStatus.ts) queries payload-locked-documents with document.value: { in: ids }. document is a polymorphic relationship to every collection, so the SQL adapters compare the ids against one column per collection and bind collections × ids parameters. D1 allows 100 bound parameters, so with around 15 collections the limit is reached at about 7 documents. Related: #17493, #14766 (limitedBoundParameters only covers id queries).
Ran into this exact Cloudflare D1 variable ceiling (SQLITE_MAX_VARIABLE_NUMBER = 100, vs standard SQLite's 999/32766) during bulk deletes, when the payload_locked_documents_rels cleanup expands inArray parameters across every relation column at once.
Until @payloadcms/db-d1 chunks that internal locked-document query natively, you can unblock production deletes without patching node_modules by batching IDs in a custom endpoint or hook:
Running sequential payload.delete({ collection, where: { id: { in: chunk } } }) calls of safeChunkSize keeps the generated WHERE (... OR ...) bind count under D1's 100-parameter limit across all relation joins.
Hi @r1tsuu, a quick process question, since you're assigned to most of the issues I reported recently (#19232, #19233, #19242, #19251).
For each of them I opened a PR with a failing test and a fix (#19235, #19243, #19252, plus #19237 for #19234). None of them has had a review yet, which is fine - I'd just like to know how to report bugs in a way that's most useful to you:
Are PRs from reporters for v4 beta bugs helpful, or do you prefer to fix them yourselves and only get a minimal reproduction (failing test) from me?
If PRs are welcome: is there anything that would make them easier to review or land (scope, test location, separate PRs per adapter, etc.)?
Either way works for me; I patch locally in the meantime. I'd just rather not flood you with PRs you don't need, and equally not hold back ones that would actually help.
Activity
Tthanh2k6 commentedon Oct 31, 2026
Ran into this exact Cloudflare D1 variable ceiling (
SQLITE_MAX_VARIABLE_NUMBER = 100, vs standard SQLite's 999/32766) during bulk deletes, when thepayload_locked_documents_relscleanup expandsinArrayparameters across every relation column at once.Until
@payloadcms/db-d1chunks that internal locked-document query natively, you can unblock production deletes without patchingnode_modulesby batching IDs in a custom endpoint or hook:const safeChunkSize = Math.max(1, Math.floor(90 / (relationSlugs.length + 2)));Running sequential
payload.delete({ collection, where: { id: { in: chunk } } })calls ofsafeChunkSizekeeps the generatedWHERE (... OR ...)bind count under D1's 100-parameter limit across all relation joins.digitalwerber commentedon Nov 14, 2026
Hi @r1tsuu, a quick process question, since you're assigned to most of the issues I reported recently (#19232, #19233, #19242, #19251).
For each of them I opened a PR with a failing test and a fix (#19235, #19243, #19252, plus #19237 for #19234). None of them has had a review yet, which is fine - I'd just like to know how to report bugs in a way that's most useful to you:
Either way works for me; I patch locally in the meantime. I'd just rather not flood you with PRs you don't need, and equally not hold back ones that would actually help.
Thanks for all the work you're putting into v4!