title: Read very slow from a database
body: <p>I use spring boot with spring data jpa, hibernate and oracle.</p>
  <p>Actually, I my table I have arount 10 millions of record, I need to do some operation, write info to a file and after delete the record.</p>
  <p>It's a basic sql query</p>
  <pre><code>select * from zzz where  status = 2;
  </code></pre>
  <p>I done a test without doing operation and delete record</p>
  <pre><code>    long start = System.nanoTime();
      int page = 0;
      Pageable pageable = PageRequest.of(page, LIMIT);
  
      Page&lt;Billing&gt; pageBilling = billingRepository.findAllByStatus(pageable);
  
      while (true) {
          for (Billing: pageBilling .getContent()) {
              //process
              //write to file
              //delete element
          }
  
          if (!pageBilling .hasNext()) {
              break;
          }
  
          pageable = pageBilling .nextPageable();
          pageBilling = billingRepository.findAllByStatus(pageable);
  
      }
      long end = System.nanoTime();
      long microseconds = (end - start) / 1000;
      System.out.println(microseconds + &quot; to write&quot;);
  </code></pre>
  <p>Result it's bad, with a limit of 10 000, that took 157 minutes, with 100 000 28 minutes, with millions 19 minutes.</p>
  <p>It's there a better solution to increase performance?</p>