2

我有应用程序在数据库中并行插入数据块(从技术上讲,很多本机 INSERT 查询在 EntityManager 对象上执行)。

我现在正试图了解如何加速这些插入。数据库主机和应用程序主机上没有任何显着的处理器负载和 io 等待时间,服务器之间几乎没有延迟。在 VisualJVM 采样器中,我可以看到 com.mchange.v2.resourcepool.Basicresourcepool.Awaitavailable() 方法花费了大约 80% 的应用程序运行时间。

有人知道这种方法到底在做什么吗?我尝试在 JPA 的连接池相关属性中增加/减少连接池 max_size 数,但没有看到任何显着差异。任何其他建议如何加快插入速度表示赞赏。

请参阅以下为应用程序提供持久性的 EntityManagerFactory bean 的属性:

hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
hibernate.connection.username=
hibernate.connection.password=
hibernate.connection.driver_class=jpa.connection.driver_class
hibernate.connection.url=
hibernate.connection.dialect=org.hibernate.dialect.OracleDialect
hibernate.connection.autoReconnect=true
hibernate.c3p0.min_size=3
hibernate.c3p0.max_size=100 /* tried different values - not much difference  */
hibernate.c3p0.timeout=1800 
hibernate.c3p0.max_statements=15000 
hibernate.c3p0.acquire_increment=1
hibernate.c3p0.validate=false
hibernate.c3p0.format_sql=false
hibernate.c3p0.show_sql=false
hibernate.c3p0.idle_test_period=240
hibernate.c3p0.maxIdleTime=0
4

1 回答 1

1

尝试批处理您的 INSERT 查询。即为几个 INSERT 收集一些数据并将其作为单个 INSERT 查询运行。

于 2013-10-01T14:14:19.370 回答