简体   繁体   中英

Oracle insert optimization using JDBC Driver

I am inserting 1 million records in an empty oracle table. In order to improve insert performance I have tried following optimizations:

  • giving /*+ APPEND */ hint in insert query
  • disabling index before insert and then re-enabling it once insertion is done
  • enabling nologging on the table.

However, I am not able to see any improvement in the insert performance. I am not able to figure out why.

Note that I am using org.springframework.jdbc.core.JdbcTemplate#batchUpdate for inserting records and I am inserting records in the batch of 20000.

Earliar Oracle has published Document regarding Performance tuning for JDBC: Oracle JDBC Memory Management

Here are the few tips

  1. Optimise the batch size ,depending on your oracle configuration.

  2. Cache the preparedstatement and use the same statement for all batches (Need cleanup) or Use statement pooling (Oracle JDBC Driver Supports it. See the above document).

  3. Oracle has few Performance extensions defined: Performance Extensions . Instead of addBatch use sendBatch for improving batch performance.See Example 23-1 in above document. 1


[1] Oracle style batching using setExecuteBatch and sendBatch was desupported in 12.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM