0

I want to know if it is considered correct / safe to pass a list of about 10000-20000 objects (f.e. Long or String) to an IN query by using a spring-data repository interface.

The class and method could look like this:

@Repository
public interface TransactionsRepository extends JpaRepository<TransactionsEntity, Long> {

    List<TransactionsEntity> findByCustomerIdIn(List<Long> customerIdList);
}

Maybe there is another way of doing such query more efficiently?

Deniss M.
  • 3,617
  • 17
  • 52
  • 100
  • What are you trying to achieve? – Moshe Arad Nov 06 '16 at 21:25
  • Optimise query times and performance – Deniss M. Nov 06 '16 at 21:26
  • I meant what are you trying to do? Because I thought about loading the 10k - 20k objects into list and use stream Java 8 to filter – Moshe Arad Nov 06 '16 at 21:28
  • I cannot use java 8 on this project. I need to understand if it is safe to pass such a big list to an IN query by using spring repository interface. – Deniss M. Nov 06 '16 at 21:30
  • @AlanHay multiple ins cannot be used because my list is dynamic. Meanwhile I have solved this by splitting up my list into smaller ones. – Deniss M. Nov 07 '16 at 20:23
  • Which is one of the proposed solutions in the question linked to. – Alan Hay Nov 07 '16 at 20:27
  • @AlanHay the popular proposal is to use a temp table and in my case I have no privileges to go with it. You could argue, but there is nothing said about jpa or spring data. – Deniss M. Nov 07 '16 at 20:29
  • There is nothing special about JPA or Spring Data. If you're looking for performance, you have much bigger worries. Passing 20k elements in an IN clause doesn't even work. – Tunaki Nov 07 '16 at 22:13

0 Answers0