Seed batches: test chunked inserts with a lowered chunk size
Test and deploy / test (push) Successful in 1m57s
Test and deploy / deploy (push) Successful in 4m7s

The 6,000-file test took 29 s and failed CI; 120 files in chunks of 50
cover the same path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-06 00:20:17 +02:00
1 parent 953bbe9e39
commit 9ae15ed26f
3 files changed
+25 -21

No files matched your search

+4 -4
View File
@@ -36,8 +36,8 @@ export function loadedSegments(stored: Buffer | null): Segment[] {
return stored ? unpackSegments(stored) : []
}
/** Rows per INSERT, well below Postgres' 65,535 bind parameters. */
export const INSERT_ROWS = 2000
/** Rows per INSERT, well below Postgres' 65,535 bind parameters (tests lower it). */
export const insertLimits = { rows: 2000 }
class FileStore {
/**
@@ -71,8 +71,8 @@ class FileStore {
if (rows.length === 0) return []
// A statement takes at most 65,535 parameters: ~5,400 rows of 12 columns.
const inserted: { id: number; filename: string }[] = []
for (let i = 0; i < rows.length; i += INSERT_ROWS) {
const chunk = await client.knexQuery().table('files').insert(rows.slice(i, i + INSERT_ROWS)).onConflict().ignore().returning(['id', 'filename'])
for (let i = 0; i < rows.length; i += insertLimits.rows) {
const chunk = await client.knexQuery().table('files').insert(rows.slice(i, i + insertLimits.rows)).onConflict().ignore().returning(['id', 'filename'])
for (const row of chunk) inserted.push({ id: Number(row.id), filename: row.filename })
}
return inserted