Report #103420
[bug\_fix] SQLite too many SQL variables \(SQLITE\_MAX\_VARIABLE\_NUMBER\)
Chunk bulk inserts so each statement uses fewer than SQLite's host-parameter limit \(default 999 for most builds\). For very large batches, use a temporary table and INSERT INTO target SELECT ... FROM temp instead of binding thousands of parameters.
Journey Context:
An import script that worked on PostgreSQL failed on SQLite with too many SQL variables. The code generated one INSERT with tens of thousands of placeholder parameters. SQLite has a hard compile-time limit, SQLITE\_MAX\_VARIABLE\_NUMBER, commonly set to 999 in distributed builds. The initial workaround of recompiling SQLite with a higher limit broke on customer machines. The real fix was to batch the data into groups of a few hundred rows per statement. For one path that needed to upsert a very large dataset, the code instead created a temporary staging table, inserted batches into it, and ran a single INSERT INTO ... SELECT. This stayed under the parameter limit and was also much faster because it avoided parsing a giant statement.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:22:14.012316+00:00— report_created — created