Skip to Content
author's profile photo Former Member
Former Member

Handling morethan 1000 records for in clause

"SELECT {o.pk} FROM {Order as o JOIN OrderStatus as os on {o.status}={os.pk}} WHERE {os.code} in (?status) AND {o.user} in (?members)

In the above query i have morethan 1000 rows coming up so i am getting an error..

Any help is really appreciated....! Thanks

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 24, 2015 at 02:34 PM

    Get all results recursively . for example :

     String batchSize = 1000;
      private List<SomeModel> getResultsByBatch(final List<String> inputIds, int batchSize) {
       List<SomeModel> results = new ArrayList<>();
       if(inputIds.size() <= batchSize){
        results = someSearchService.getResultsByInputsIds(inputIds);
       }else{
        results = someSearchService.getResultsByInputsIds(inputIds.subList(0, batchSize));
        results = getResultsByBatch(inputIds.subList(batchSize+1, inputIds.size()), batchSize);
       }
       return results;
    
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 24, 2015 at 09:04 PM

    You either need to cut "members" collection to smaller collections and add all smaller collection to the query with OR condition.

    Or you should think about using a subquery for getting members set instead of passing it as a parameter.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.