Impact of oraclejdbcfetchsize on Performance

Source: Internet
Author: User
?????? When data is retrieved through JDBC, the default value is 10 data records, that is, fetchsize is 10. Increasing this number can reduce the round-trip between the client and oracle and reduce the response time, it is recommended that this number not exceed 100 on the Internet. Otherwise, the middleware memory consumption will be high (no experiments have been conducted ). Packagecom. gg. test; importjava. SQL. Conn

?????? When data is retrieved through JDBC, the default value is 10 pieces of data, that is, the fetch size is 10. Increasing this number can reduce the round-trip between the client and oracle and reduce the response time, it is recommended that this number not exceed 100 on the Internet. Otherwise, the middleware memory consumption will be high (no experiments have been conducted ). Package com. gg. test; import java. SQL. Conn

?????? When data is retrieved through JDBC, the default value is 10 pieces of data, that is, the fetch size is 10. Increasing this number can reduce the round-trip between the client and oracle and reduce the response time, it is recommended that this number not exceed 100 on the Internet. Otherwise, the middleware memory consumption will be high (no experiments have been conducted ).

Package com. gg. test; import java. SQL. connection; import java. SQL. driverManager; import java. SQL. resultSet; import java. SQL. SQLException; import java. SQL. statement; public class FetchSize {static final String driver_class = "oracle. jdbc. driver. oracleDriver "; static final String connectionURL =" jdbc: oracle: thin: @ 10.10.29.150: 1522: ordb10 "; static final String userID =" test "; static final String userPassword = "test"; public void runTest (int fetchSize) {Connection con = null; Statement stmt = null; ResultSet rset = null; long startTime = System. currentTimeMillis (); String query_string = "SELECT * FROM test"; // test has 50 thousand records. try {Class. forName (driver_class ). newInstance (); con = DriverManager. getConnection (connectionURL, userID, userPassword); stmt = con. createStatement (); stmt. setFetchSize (fetchSize); rset = stmt.exe cuteQuery (query_string); while (rset. next () {rset. getString (1); rset. getString (2); rset. getString (3);} rset. close (); stmt. close (); long endTime = System. currentTimeMillis (); System. out. println ("fetchsize is" + fetchSize + "--- time consumed:" + (endTime-startTime);} catch (SQLException e) {e. printStackTrace ();} catch (Exception e) {e. printStackTrace () ;}} public static void main (String [] args) {FetchSize fetchSize = new FetchSize (); fetchSize. runTest (10); fetchSize. runTest (50); fetchSize. runTest (100); fetchSize. runTest (200); fetchSize. runTest (500); fetchSize. runTest (1000 );}}


Result:

Fetchsize is 10 ?? ? --- Consumed time: 22140 ms
Fetchsize is 50 ??? --- Consumed time: 13780 ms
Is fetchsize 100? --- Consumed time: 5110 ms
Is fetchsize 200? --- Consumed time: 3984 ms
Is fetchsize 500? --- Consumed time: 2625 ms
Fetchsize is 1000 --- the consumed time: 2875 ms

Author: guogang83 posted on 17:24:37 Original article link

Read: 7 Comments: 0 view comments

Original article address: Impact of oracle jdbc fetchsize on Performance.

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.