Reputation: 4672
the following code in the if condition is going to called for almost 10,000 times and in testing showing the performance issues .
if (fileUploaderIdListVo != null && fileUploaderIdListVo.size() > 0) {
for (FileUploaderIdVo fuidVo : fileUploaderIdListVo) {
if ( fuidVo.getExploded() != null && fuidVo.getExploded().equalsIgnoreCase("Y")) {
List<Rights> rightsList = rightsDao.list(fuidVo.getContractId());
int contractTitleId = Integer.parseInt(fuidVo.getContractTitleId());
List<Integer> titleRightIds = new ArrayList<Integer>();
for(Rights right: rightsList) {
if(right!=null ) {
titleRightIds.add(right.getId());
}
}
titleRightsManager.saveRightCombination("true", user.getUid(), fuidVo.getContractId(), titleRightIds, contractTitleId,new ArrayList<String>());
}
}
}
What I think of
getting the rightsList outside the the if condition 2. calling the saveRightCombination again outside the if condition
Please suggest suitable ways to improve the performance of the following code.
Upvotes: 0
Views: 87
Reputation: 39069
Your bottleneck is accessing the database, not your Java code. You can do the following:
Upvotes: 3