Improves the performance of JDBC batch operations and jdbc Performance

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.