title: how to partition a step based on the database volume
body: <p>below is my job configuration for paritioning a step.</p>
  
  <p></p>
  
  <pre><code>    &lt;!-- master step, 10 threads (grid-size)  --&gt;
      &lt;step id="masterStep"&gt;
          &lt;partition step="slave" partitioner="rangePartitioner"&gt;
              &lt;handler grid-size="10" task-executor="taskExecutor" /&gt;
          &lt;/partition&gt;
      &lt;/step&gt;
  
  &lt;/job&gt;
  
  &lt;!-- Jobs to run --&gt;
  &lt;step id="slave" xmlns="http://www.springframework.org/schema/batch"&gt;
      &lt;tasklet&gt;
          &lt;chunk reader="pagingItemReader" writer="jdbcWriter"
              processor="itemProcessor" commit-interval="1" /&gt;
      &lt;/tasklet&gt;
  &lt;/step&gt;
  </code></pre>
  
  <p>and below is my partitioning java class</p>
  
  <pre><code>    Map&lt;String, ExecutionContext&gt; result = new HashMap&lt;String, ExecutionContext&gt;();
  
      int range = 5;
      int fromId = 1;
      int toId = range;
  
      for (int i = 1; i &lt;= gridSize; i++) {
          ExecutionContext value = new ExecutionContext();
  
          System.out.println("\nStarting : Thread" + i);
          System.out.println("fromId : " + fromId);
          System.out.println("toId : " + toId);
  
          value.putInt("fromId", fromId);
          value.putInt("toId", toId);
  
          // give each thread a name
          value.putString("name", "Thread" + i);
  
          result.put("partition" + i, value);
  
          fromId = toId + 1;
          toId += range;
  
      }
  
      return result;
  </code></pre>
  
  <p>from the above configuration I can able to work with the partitioning, 10 threads will be running and each thread will process 5 records.</p>
  
  <p>there are 2 scenarios</p>
  
  <p>1.if there are only 5 records the remaining 9 threads are processing no data
  2.If there is a frequent change in the volume of data one day there is 5 records and one day there is 1 million records in this case I can not configure the grid size and range daily if I hard code them in the file.</p>
  
  <p>so now my requirement is to dynamaically threads should be processed based on the volume of the database i.e based on the no of rows in a particular table.</p>
  
  <p>please suggest me for this scenario.</p>