spring事务处理数据效率

public void allCidProduce() {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务,这样会比较安全些。
TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
List reserverCustomers = this.allReserverCustomerGetCid();
int i = reserverCustomers.size() / 100;
for (int j = 0; j < i; j++) {
List subReserverCustomers = null;
if (j == i - 1) {
subReserverCustomers = reserverCustomers.subList(100 * j, reserverCustomers.size());
} else {
subReserverCustomers = reserverCustomers.subList(100 * j, 100 * (j + 1));
}
try {
this.cidProduce(subReserverCustomers);
transactionManager.commit(status);
status = transactionManager.getTransaction(def);
} catch (Exception e) {
transactionManager.rollback(status);
}
System.out.println("============第=============" + (j + 1) * 100 + "========完成===============");
}

}

为什么第一百个数据处理很慢,后面的数据处理飞快

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问