我已经通过了HikariCP连接池,我可以说这很棒,因为我看到了良好的性能。但在这里,我担心的是我认为这种联系太多了。
情境: 我有列表对象,其中包含10004条记录,当我运行插入查询时,需要13秒才能完成操作。
数据库属性:
final HikariDataSource dataSource = new HikariDataSource();
dataSource.setMaximumPoolSize(100);
dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
dataSource.setJdbcUrl("jdbc:oracle:thin:@g9u1769.houston.hpecorp.net:1525:ODSDBD");
dataSource.setUsername("Solid_batch1");
dataSource.setPassword("solid_batch123");
dataSource.setMaxLifetime(30000);
登录
2016-08-27 11:26:01.779 [] [] [] [Hikari connection adder (pool HikariPool-0)] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-0 - Added connection oracle.jdbc.driver.T4CConnection@221e8d6a
2016-08-27 11:26:04.204 [] [] [] [Hikari connection adder (pool HikariPool-0)] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-0 - Added connection oracle.jdbc.driver.T4CConnection@3c4ecbf
2016-08-27 11:26:06.620 [] [] [] [Hikari connection adder (pool HikariPool-0)] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-0 - Added connection oracle.jdbc.driver.T4CConnection@7592f187
2016-08-27 11:26:09.038 [] [] [] [Hikari connection adder (pool HikariPool-0)] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-0 - Added connection oracle.jdbc.driver.T4CConnection@22f125f
2016-08-27 11:26:11.455 [] [] [] [Hikari connection adder (pool HikariPool-0)] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-0 - Added connection oracle.jdbc.driver.T4CConnection@605f1c17
2016-08-27 11:26:13.869 [] [] [] [Hikari connection adder (pool HikariPool-0)] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-0 - Added connection oracle.jdbc.driver.T4CConnection@42d5b6f
2016-08-27 11:26:13.975 [] [] [] [main] WARN c.h.i.i.d.manager.dao.DaoService - detail query : 13
任何人都可以帮助我减少连接创建。
答案 0 :(得分:0)
您可以减少最大池大小,因此连接将限制为该连接,然后它不会建立更多连接,而是一旦定义的连接可以通过设置自由使用:
dataSource.setMaximumPoolSize(20);