I have a JDBC application, to convert insert statements into batch I used rewriteBatchedStatements=true in MySQL connection string but I also need to limit my batch size to 100. How can I do it?
I have a JDBC application, to convert insert statements into batch I used rewriteBatchedStatements=true in MySQL connection string but I also need to limit my batch size to 100. How can I do it?
On the server side max_allowed_packet will limit the count of INSERT clobbed together by rewriteBatchedStatements. As per 5.1.8 Server System Variables:
The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function. The default is 64MB.
If you need more fine grained control you must use JDBC e.g. by calling executeBatch() after each N rows.
You can make commit of current transaction (or flush session) every 100 rows you trying to insert.