Maximum call stack for transactions

I've been trying to do a transaction over 100k rows (works at 10k) but I've been getting an error for stack size. How do I handle bigger transactions?
Transaction failed. 13 | }
14 | function mergeQueries(queries) {
15 | const result = { sql: "", params: [] };
16 | for (const query of queries) {
17 | result.sql += query.sql;
18 | result.params.push(...query.params);
^
RangeError: Maximum call stack size exceeded.
at mergeQueries (/Users/meow/Projects/psql/node_modules/drizzle-orm/sql/sql.js:18:19)
at /Users/meow/Projects/psql/node_modules/drizzle-orm/sql/sql.js:52:26
at /Users/meow/Projects/psql/node_modules/drizzle-orm/pg-core/query-builders/insert.js:133:53
at /Users/meow/Projects/psql/node_modules/drizzle-orm/pg-core/query-builders/insert.js:141:19
at /Users/meow/Projects/psql/src/db/seed.ts:124:6
Transaction failed. 13 | }
14 | function mergeQueries(queries) {
15 | const result = { sql: "", params: [] };
16 | for (const query of queries) {
17 | result.sql += query.sql;
18 | result.params.push(...query.params);
^
RangeError: Maximum call stack size exceeded.
at mergeQueries (/Users/meow/Projects/psql/node_modules/drizzle-orm/sql/sql.js:18:19)
at /Users/meow/Projects/psql/node_modules/drizzle-orm/sql/sql.js:52:26
at /Users/meow/Projects/psql/node_modules/drizzle-orm/pg-core/query-builders/insert.js:133:53
at /Users/meow/Projects/psql/node_modules/drizzle-orm/pg-core/query-builders/insert.js:141:19
at /Users/meow/Projects/psql/src/db/seed.ts:124:6
1 Reply
Mario564
Mario5645mo ago
Hi there. Pretty sure this issue isn't specific to transactions but rather a query that uses a lot of params. This is a limitation with JS, not specifically Drizzle. There are plans to support writing tons of rows in a neat way but it's not currently supported in many drivers. I think the best thing here would be to break down all the 100k rows into chunks of, let's say, 10k each.
Want results from more Discord servers?
Add your server