批量更新执行中的更新查询需要很长时间
Update query inside the Batch update execution is taking long time
System.out.println("multipleBatchUpdateCheckErroreValues.update starting time------"+ new DateTime());
multipleBatchUpdateCheckError(
vSql.toString(), //sql query
pPriceMap.toList(), //rows
50, //batch size
new ObjectPreparedStatementSetter() {
public void setValues(Object row, PreparedStatement ps, int rowNo) throws SQLException {
Price vPrice = (Price) row;
prepareValues(vPrice, ps, UPDATE);
}
});
}
System.out.println("multipleBatchUpdateCheckErroreValues.update ending time------"
+ new DateTime());
在上面的代码中,更新花费了太多时间才能完成。如何优化以下代码执行时间?
SQL查询是
UPDATE PRICE_T
SET TO_TIME = ?,
PRICE_EXCLUDING_TAX = ?,
PRICE_INCLUDING_TAX = ?,
REASON = ?,
PRIORITY_TYPE = ?,
TRANS_TIME = ?,
DEL_TIME = ?,
UPD_TIME = ?
WHERE CLASS = ?
and CLASS_TYPE = ?
and COUNTRY_CODE = ?
and ITEM_NO = ?
and ITEM_TYPE = ?
and CURRENCY_CODE = ?
and PRICE_TYPE = ?
and FROM_TIME = ?
Total rows 10k, columns 14, time taking to process is 35 mins.
在where子句的8列全部创建索引后,执行时间减少到1秒
System.out.println("multipleBatchUpdateCheckErroreValues.update starting time------"+ new DateTime());
multipleBatchUpdateCheckError(
vSql.toString(), //sql query
pPriceMap.toList(), //rows
50, //batch size
new ObjectPreparedStatementSetter() {
public void setValues(Object row, PreparedStatement ps, int rowNo) throws SQLException {
Price vPrice = (Price) row;
prepareValues(vPrice, ps, UPDATE);
}
});
}
System.out.println("multipleBatchUpdateCheckErroreValues.update ending time------"
+ new DateTime());
在上面的代码中,更新花费了太多时间才能完成。如何优化以下代码执行时间?
SQL查询是
UPDATE PRICE_T
SET TO_TIME = ?,
PRICE_EXCLUDING_TAX = ?,
PRICE_INCLUDING_TAX = ?,
REASON = ?,
PRIORITY_TYPE = ?,
TRANS_TIME = ?,
DEL_TIME = ?,
UPD_TIME = ?
WHERE CLASS = ?
and CLASS_TYPE = ?
and COUNTRY_CODE = ?
and ITEM_NO = ?
and ITEM_TYPE = ?
and CURRENCY_CODE = ?
and PRICE_TYPE = ?
and FROM_TIME = ?
Total rows 10k, columns 14, time taking to process is 35 mins.
在where子句的8列全部创建索引后,执行时间减少到1秒