javaspringhibernatejdbcorm

What is the difference between hibernate.jdbc.fetch_size and hibernate.jdbc.batch_size?


I am trying to tune my application, came across some blogs speaking about the batch fetch and batch select, and putting my understanding as follows.

Is my understanding correct? Also, what are the optimal values for these parameters?


Solution

  • Both of these options set properties within the JDBC driver.

    In the first case, hibernate.jdbc.fetch_size sets the statement's fetch size within the JDBC driver, that is, the number of rows fetched when there is more than one row of result on select statements.

    In the second case, hibernate.jdbc.batch_size determines the number of updates (inserts, updates, and deletes) that are sent to the database at one time for execution. This parameter is necessary to do batch inserts, but must be coupled with the ordered inserts parameter and the JDBC driver's capability to rewrite the inserts into a batch insert statement.

    See this link.