[SOLVED] When running a big bulk insert I get an error, MAX_PARAMETERS_EXCEEDED
I want to run a transaction that runs a large bulk insert but I get this error:
12 Replies
And by large I mean about 50,000 items each having around 10 parameters.
I also tried to put them in arrays of 1000 and then insert but after a few inserts I ended up getting the same error again.
Can you do it in a for loop?
No driver is going to like you doing
db.insert(users).values([array with 50000 items])
But you could do
Yeah, I ended up doing this.
But can't I do it in like 100 chunks? I feel like it should be doable 😄
Sure you can, you could do:
But you gotta be careful with overflowing
Maybe you could change it to
array.slice(i, Math.min(i+100, array.length))
Yep, I'll give this a try.
Yay, works with batches of 100 😁.
Thanks
how to do bulk update in drizzle orm
The same way you do a single insert, but instead of passing a single object you pass an array of objects.
i used pass like that but when i giving target value another column other than primary key
getting errors like target vaue must be a primary key
Can you send the error and how your inserting the data?
Preferably in another help thread
Is it a good idea to use Promise.all here?
Depends how you want to send your queries. With promise.all they will all be sent at the same time. With for await, they will be sent 1 at a time
Thx!