I'm new to Jpa. I have a List list which has about 10000-50000 client objects in it.
I'm iterating through this list and querying each client if he has made any purchases like this:
List<TransactRepViewModel> temporalList = transactRepViewRepository
.findByClientIdAndClDateBetween(clieTabModel.getClientId(),
reportInterval.getStartDate(),
reportInterval.getEndDate());
TransactRepViewRepository.class method looks like this:
List<TransactRepViewModel> findByClientIdAndClDateBetween(
String clientId, Date startDate, Date endDate) throws DataAccessException;
I would really like to improve my search time, since iterating through such amount of clients takes quite some time. Are there any technique I could use?
inclause to pass many client IDs at once. But beware that most databases limit the number of values inside the in clause, and/or the length of the query. Oracle for example has a limit of 1000. Still, that would reduce the number of queries from 50000 to 50.