views:

24

answers:

1

I have a table having 4 columns and I need to insert over 5k rows. Is it good to insert them using 1 query, or each row having its separate query. The database is mysql.

A: 

I guess it would perform better if you insert them in one insert sentence. Keep in mind that this way, if one of the insertion fails, the whole insertion will fail. On the other hand, if you run in multiple sentences, if one insertion fails, the other insertions could continue with no problems. Unless you are running them in a single transaction context.

Pablo Santa Cruz
How about if I make bunch of them like for every 5-10 rows, I make single query and execute them. Is there any such formula that can give me this number ?
harrisunderwork