node-postgres not being able to handle large inserts?
See original GitHub issueI am getting this error while executing a large transaction.
{
[error: bind message supplies 14472 parameters, but prepared statement "" requires 80008]
}
- I am inserting 10001 rows and each row has 8 columns.
- I can confirm that I did supply all 80008 parameters but for some reason, I keep getting this bind message supplies 14472 parameters error
- My work_mem is 1mb and maintenance_work_mem is 16mb
My resolution:
I had to write the sql query into a file (‘insert.sql’) and then I went into postgres console and did \i insert.sql
and then it was fine.
Note: With node-postgres, I use node-sql to generate prepared statements, however, when I did \i insert.sql
I produced a raw sql statement.
Some guesses: Idea 1: Maybe because I am inserting so many rows at once that postgres dies after processing 14472 parameters?
I have had similar problems with node-postgres in the past where when I used node-postgres to do large inserts, it seemed not to be able to handle it well. And with large inserts I always resort back to \i insert.sql
Issue Analytics
- State:
- Created 9 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
node-postgres will not insert data, but doesn't throw errors either
js and I have a problem inserting data. The function: function addItems(listId, listItems, handle) { if (!listItems) { ...
Read more >Optimizing Conditional Bulk Insert in Node.js + PostgreSQL
I described term conditional bulk insert as an operation where many records need to be inserted to DB at once, while ensuring there's...
Read more >Processing large volumes of data safely and fast using Node ...
About designing a PostgreSQL client for Node.js. Last week I have shared lessons learned scaling PostgreSQL database to 1.2bn records/month. In ...
Read more >Documentation: 15: 13.2. Transaction Isolation - PostgreSQL
If MERGE attempts an INSERT and a unique index is present and a duplicate row is concurrently inserted, then a uniqueness violation error...
Read more >7 Best Practice Tips for PostgreSQL Bulk Data Loading - EDB
The UNLOGGED mode ensures PostgreSQL is not sending table write operations to the Write Ahead Log (WAL). This can make the load process ......
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
Yeah I think it should be super cheap, can just do
The 16-bit hard cap on params is specified as part of the postgres protocol and is a constraint within postgres itself. Here’s the code that writes the count of params. This library could probably throw a friendlier error rather than just having the query crash with a param count mis-match…but it’s nothing that we can actually “fix” on our side.