Improves the performance of JDBC batch operations and jdbc Performance
JDBC
When you use the insert into... VALUES () statement to INSERT data in batches, you should use the JDBC PreparedStatement batch operation method instead of using one execution method.
For example (Source: http://superjavason.iteye.com/blog/255423 ):
For example, the Code has three key processing steps:
1) disable automatic submission
2) addBatch
3) executeBatch
Using this method, the SQLite test results were significantly improved, from 10000/s to 100000/s (data is for reference only and cannot be used as a decision basis)
Note that this method is only suitable for batch execution of SQL statements of the same structure. This method cannot be used for SQL statements of different structures, because PreparedStatement specifies the SQL statement during initialization.
MySQL
After the preceding parameters are used, MySQL performance is also improved, but the improvement is not obvious. After searching, make sure that it is related to the following two parameters:
- RewriteBatchedStatements = true
By default, batch processing is disabled in mysql. You can use this parameter to enable batch. This parameter can overwrite the SQL statement submitted to the database.
- Useserverprepsponts = false
If useserverprep;ts = false is disabled, use com. mysql. jdbc. PreparedStatement to assemble local SQL statements. Is it replaced when it is finally sent to the db? Final SQL
After testing, the batchcompute performance of mysql increased from over 1000 to over 50000 after these two parameters are enabled.
See http://blog.csdn.net/whucyl/article/details/20838079 for details