比如从oracle中查询10万条数据,做业务处理后再更新。 查询时可以根据单表的主键做partition,并发读取后,在java中组装。 sql: AND MOD(ora_hash(INVENTORY_ID),#{modValue})=#{currentModValue}
java: public List<TrInventoryEntity> queryTrInventoryComplex(TrInventoryEntity entity) throws InterruptedException, ExecutionException { List<TrInventoryEntity> result=new ArrayList<TrInventoryEntity>(); long counts=baseMapper.queryTrInventoryListCounts(entity); if(counts<PickUpUtils.SIZE_BIG) { return queryTrInventoryList(entity); } long modValue=counts/PickUpUtils.SIZE_BIG+1; entity.setModValue(modValue); List<Callable<List<TrInventoryEntity>>> tasks = new ArrayList<Callable<List<TrInventoryEntity>>>(); Callable<List<TrInventoryEntity>> task = null; for (long i = 0; i < modValue; i++) { long finalI = i; task = new Callable<List<TrInventoryEntity>>() { @Override public List<TrInventoryEntity> call() throws Exception { TrInventoryEntity entityPiece =SerializationUtils.clone(entity); entityPiece.setCurrentModValue(finalI); return baseMapper.queryTrInventoryList(entityPiece); } }; tasks.add(task); } List<Future<List<TrInventoryEntity>>> results =DynamicTask.es.invokeAll(tasks); for(int i=0;i<results.size();i++) { result.addAll(results.get(i).get()); } return queryTrInventoryForExport(result); }