Prepared statement contains too many placeholders
See original GitHub issueBug description
When creating many 1000s of rows (in my case also inside a transaction) in a MySQL database we hit:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Server(ServerError { code: 1390, message: "Prepared statement contains too many placeholders", state: "HY000" })) })
I don’t think these is an obvious workaround in the Prisma ecosystem.
How to reproduce
You can reproduce this with a large Prisma transaction given your available schema.
In my case this looks like:
const results = await this.prisma.$transaction([
this.prisma.parent.update(/** ... */)
this.prisma.child1.createMany(/** ... */),
this.prisma.child1.deleteMany(/** ... */),
this.prisma.child2.createMany(/** ... */),
this.prisma.child2.deleteMany(/** ... */),
]);
Expected behavior
I think this is more like a feature request, but I’d expect the createMany
or$transaction
to allow some opportunity to support a batchSize
/ chunkSize
/ transactionChunk
, like for example Knex BatchInsert or Sequelize Batch Create
Prisma information
Environment & setup
- OS: Mac OS
- Database: MySQL 8
- Node.js version: v12.18.1
Prisma Version
prisma : 2.26.0
@prisma/client : 2.26.0
Current platform : darwin
Query Engine : query-engine 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine : migration-engine-cli 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 9b816b3aa13cc270074f172f30d6eda8a8ce867d (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 9b816b3aa13cc270074f172f30d6eda8a8ce867d
Studio : 0.408.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Import of 50K+ Records in MySQL Gives General error: 1390 ...
Import of 50K+ Records in MySQL Gives General error: 1390 Prepared statement contains too many placeholders · If you import let´s say 100...
Read more >Too many placeholders - Laracasts
the error message "Prepared statement contains too many Placeholders" is clear, the values you provide in the query is less than the placeholders...
Read more >Prepared statement contains too many placeholders in Preload
The error is Error 1390: Prepared statement contains too many placeholders. best would be if large where in querys get chunked.
Read more >101630: Consider increasing placeholder limit to be > 64k
Description: I see this error message in Orchestrator: Error 1390: Prepared statement contains too many placeholders.
Read more >General Error 1390 Prepared statement contains too many ...
It's not the real solution but an instruction to use it wisely. There is a limit of 65,535 (2^16-1) placeholders in MySQL. So...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has been fixed in Prisma 3.4.0. You will need to upgrade to benefit from this improvement.
I have the same error with a single update call:
This is my model:
This is the error: