使用事务和不使用事务插入速度差距可以有几百倍。。。。
// statement.execute("begin;");
long startTime = System.currentTimeMillis();
for (int i = 0;i<baseInfo.size();i++){
StockInfo stockInfo = baseInfo.get(i);
String sql = getSqlForInsertIntoStockBase(stockInfo);
statement.execute(sql);
PrintUtil.print("当前执行第+"+i+"条:"+stockInfo.name+" "+stockInfo.code );
}
// statement.execute("commit;");
不使用事务
当前执行第+3677条:沃尔德 688028
共耗时:40s
使用事务
当前执行第+3677条:沃尔德 688028
共耗时:0.126s
---------------这好夸张。。。