我正在尝试使用 postgres
CopyManager.copyIn()
进行批量插入。我的数据源是 c3p0 ComboPooledDataSource
。
sql语句是批处理的:
dataSource.getConnection().getCopyAPI().copyIn(sql, items);//伪代码
现在,为了进一步加快数据库插入速度(预处理后导入数百 GB),我尝试在异步线程中发送 copyIn
命令。
但是如果数据库位于单个磁盘文件系统上,这有意义吗?这会提高性能吗?
我如何才能真正验证 copyIn 是否并行使用连接池?
我尝试了 VisualVM
MBeans
屏幕,在其中我可以看到单个 PooledDataSource
条目。但我怎么知道池已被使用并且项目已发送到数据库并行?
最佳答案
But does this make sense if the database is located on a single disk filesystem? Would this gain performance?
如果它正在旋转,则可能不会,而且大量并发肯定没有什么好处。对于 SSD,有时会产生相当显着的改进。很大程度上取决于驱动器。
I tried VisualVM MBeans screen, where i can see a single PooledDataSource entry. But how can I know that the pool is used and items are send to DB parallel?
查看数据库中的 pg_stat_activity
并查看应用中是否有多个并发 COPY
命令。
关于java - 如何将 CopyManager 与连接池数据源一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29792401/