jmoiron / sqlx

general purpose extensions to golang's database/sql
http://jmoiron.github.io/sqlx/
MIT License
16.3k stars 1.09k forks source link

issue with Bulk Insert in Planetscale: Argument Mismatch Error When Scaling Up #932

Open Imran-imtiaz48 opened 4 months ago

Imran-imtiaz48 commented 4 months ago

I'm encountering an issue in one of my write-heavy applications when writing into Planetscale (MySQL). I'm getting the error: sql: expected 28556 arguments, got 290700. Interestingly, the inserts work correctly when the number of rows is smaller.

Is there a known issue with scaling up inserts, such as an upper boundary where this breaks?

I'm using bulk insert with tx.NamedExec() and passing in a struct slice (no pointers). The struct has around 15 fields. If anyone has ideas about the root cause (whether it's database/sql, github.com/go-sql-driver/mysql, Planetscale limitations, or a missing MySQL setting), I would appreciate any suggestions.

Kangaroux commented 4 months ago

Can you post a code sample? A mismatch likely indicates an error in the logic rather than a limit that's being exceeded. I've experienced something similar in Django with a bad JOIN that caused a column mismatch.