title: Spring Data JPA Pagination without count query
body: <p>According to Spring docs <a href="https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.special-parameters" rel="nofollow noreferrer">https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.special-parameters</a> returning with <code>List</code> should not issue count query.</p>
  <p>But with my spring it goes kinda strange.</p>
  <p>When running page request with page <code>1</code> it works without count query which i suppose is right.</p>
  <p><a href="https://i.stack.imgur.com/N13BK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N13BK.png" alt="Requested with page 1" /></a></p>
  <p>But when I invoke repository with page <code>2</code>(or above) suddenly it does a count query after select query which I didn't expect.</p>
  <p><a href="https://i.stack.imgur.com/b2QLQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b2QLQ.png" alt="Requested with page 2 or above" /></a></p>
  <p>Is there any way that I could make count query <strong>not issued</strong> with using Pageable?</p>
  <p>Repository and service code for what i did.</p>
  <pre class="lang-java prettyprint-override"><code>@Repository
  public interface ArticleRepository extends CrudRepository&lt;Article, Long&gt; {
    // Slice was also tested and did issue count query from page 2
    List&lt;Article&gt; findAll(Pageable pageable);
  } 
  
  @Service
  public class ArticleService {
    private final ArticleRepository articleRepository;
  
    @Autowired
    public ArticleService(
        ArticleRepository articleRepository) {
      this.articleRepository = articleRepository;
    }
  
    public List&lt;Article&gt; getArticles(int page) {
      PageRequest pageRequest = PageRequest.of(page, 50, Sort.by(&quot;createdAt&quot;).descending());
      return articleRepository.findAll(pageRequest);
    }
  }
  
  </code></pre>